NetBSD Problem Report #53968

From mlelstv@hoppa.1st.de  Sun Feb 10 07:32:03 2019
Return-Path: <mlelstv@hoppa.1st.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id BF1E37A1B1
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 10 Feb 2019 07:32:02 +0000 (UTC)
Message-Id: <20190210073138.5BC358@hoppa.1st.de>
Date: Sun, 10 Feb 2019 08:31:38 +0100 (CET)
From: mlelstv@netbsd.org
Reply-To: mlelstv@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: t_ubsan check broken on big endian
X-Send-Pr-Version: 3.95

>Number:         53968
>Category:       bin
>Synopsis:       t_ubsan check broken on big endian
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 10 07:35:00 +0000 2019
>Last-Modified:  Wed Feb 20 11:45:01 +0000 2019
>Originator:     Michael van Elst
>Release:        NetBSD 8.99.34
>Organization:

>Environment:


System: NetBSD dummy 8.99.34 NetBSD 8.99.34 (DUMMY) #51: Sat Feb 9 14:09:19 CET 2019 mlelstv@gossam:/home/netbsd-current/obj.amiga/home/netbsd-current/src/sys/arch/amiga/compile/DUMMY amiga
Architecture: m68k
Machine: amiga
>Description:

t_ubsan fails with

load_invalid_value_bool: [0.220474s] Failed: /home/netbsd-current/src/tests/lib/libc/misc/t_ubsan.c:99: buffer != 0 not met

The reason is that ubsan doesn't see an error, because the test is bogus.

static void
test_load_invalid_value_bool(void)
{
        volatile int a = atoi("10");
        volatile bool b = *(REINTERPRET_CAST(volatile bool *, &a));

        raise(b ? SIGSEGV : SIGBUS);
}

This reads the first byte of an integer variable and assigns it
to a bool variable. For bigendian platforms that first byte is
zero.

>How-To-Repeat:
Run atf tests on a big-endian arch.

>Fix:
Use a test value that has only invalid bytes. The same also helps
the load_invalid_value_enum test. The test value must use at least
as many bytes as a bool (or enum).

>Audit-Trail:
From: "Kamil Rytarowski" <kamil@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53968 CVS commit: src/tests/lib/libc/misc
Date: Wed, 20 Feb 2019 09:50:09 +0000

 Module Name:	src
 Committed By:	kamil
 Date:		Wed Feb 20 09:50:09 UTC 2019

 Modified Files:
 	src/tests/lib/libc/misc: t_ubsan.c

 Log Message:
 Try to make load_invalid_value_bool portable to Big-Endian

 PR bin/53968 by Michael van Elst


 To generate a diff of this commit:
 cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/misc/t_ubsan.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Kamil Rytarowski" <kamil@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53968 CVS commit: src/tests/lib/libc/misc
Date: Wed, 20 Feb 2019 11:40:41 +0000

 Module Name:	src
 Committed By:	kamil
 Date:		Wed Feb 20 11:40:41 UTC 2019

 Modified Files:
 	src/tests/lib/libc/misc: t_ubsan.c

 Log Message:
 Unify the style of t_ubsan tests

 Apply similar change for load_invalid_value_bool in
 test_load_invalid_value_enum.

 Follow up of PR bin/53968 by Michael van Elst


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/misc/t_ubsan.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.