NetBSD Problem Report #51460
From www@NetBSD.org Sat Sep 3 16:12:56 2016
Return-Path: <www@NetBSD.org>
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 "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 8C61B7A265
for <gnats-bugs@gnats.NetBSD.org>; Sat, 3 Sep 2016 16:12:56 +0000 (UTC)
Message-Id: <20160903161255.251CD7A2B8@mollari.NetBSD.org>
Date: Sat, 3 Sep 2016 16:12:55 +0000 (UTC)
From: ray.phillips@gmail.com
Reply-To: ray.phillips@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Source code bugs
X-Send-Pr-Version: www-1.0
>Number: 51460
>Category: kern
>Synopsis: Source code bugs
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Sep 03 16:15:00 +0000 2016
>Last-Modified: Mon Sep 05 17:45:00 +0000 2016
>Originator: Ray Phillips
>Release: 7.0.1
>Organization:
>Environment:
NetBSD aw135.sbs.uq.edu.au 7.0.1 NetBSD 7.0.1 (GENERIC.201605221355Z) amd64
>Description:
I hesitate to submit this report because I've no experience with kernel programming. Hopefully it's not a bogus report...
I've been attempting to get Hubert Feyrer's g4u 2.6beta1:
http://www.feyrer.de/g4u/g4u-2.6beta1.tgz
to build with NetBSD 7.0.1 source code and found it was necessary to edit two files in the 7.0.1 source to get them to compile:
usr/srcsys/dev/acpi/fujhk_acpi.c
usr/src/sys/kern/core_elf32.c
The errors were (as shown in the "Fix to the problem if known" section of this send-pr):
/usr/src/sys/dev/acpi/fujhk_acpi.c:262:10: error: 'irb' may be used uninitialized in this function
/usr/src/sys/kern/core_elf32.c:513:12: error: conflicting types for 'coredump_elf32'
>How-To-Repeat:
It's probably not necessary, but if you like I can send you my modified g4u-2.6beta1.tgz if you want to follow the same steps I have, but you can see from the error messages why the compile stopped.
They're obviously not critical problems since NetBSD/i386 7.0.1 has been compiled successfully and released. I suppose the g4u-build script must use different compiler settings to have produced these errors.
>Fix:
Edit ./sys/dev/acpi/fujhk_acpi.c :
# diff -u ./sys/dev/acpi/fujhk_acpi.c.orig ./sys/dev/acpi/fujhk_acpi.c
--- ./sys/dev/acpi/fujhk_acpi.c.orig 2016-08-31 21:55:27.000000000 +1000
+++ ./sys/dev/acpi/fujhk_acpi.c 2016-08-31 22:13:25.000000000 +1000
@@ -246,6 +246,7 @@
uint32_t irb;
int i, index;
+ irb = 0; /* make sure irb has been initialized */
for (i = 0; i < max_irb_buffer_size; i++) {
if (fujitsu_hk_get_irb(sc, &irb) || irb == 0)
return;
#
Without that change this error occurred:
# compile G4U-KERNEL/fujhk_acpi.o
/usr/src/obj.i386/tooldir-NetBSD/bin/i486--netbsdelf-gcc -msoft-float -mno-mmx -
mno-sse -mno-avx -ffreestanding -fno-zero-initialized-in-bss -g -Os -fstack-prot
ector -Wstack-protector --param ssp-buffer-size=1 -fno-strict-aliasing -fno-comm
on -std=gnu99 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -W
missing-prototypes -Wstrict-prototypes -Wold-style-definition -Wswitch -Wshadow
-Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-pointer-sign -Wno-attribu
tes -Wextra -Wno-unused-parameter -Wold-style-definition -Wno-sign-compare -marc
h=i486 -mtune=pentiumpro --sysroot=/usr/src/obj.i386/destdir -Di386 -I. -I/usr/s
rc/sys/../common/include -I/usr/src/sys/arch -I/usr/src/sys -nostdinc -DCHILD_MA
X=1024 -DOPEN_MAX=1024 -DMSGBUFSIZE=50000 -DHALT_ON_PANIC -DMAXUSERS=2 -D_KERNEL
-D_KERNEL_OPT -std=gnu99 -I/usr/src/sys/lib/libkern/../../../common/lib/libc/qu
ad -I/usr/src/sys/lib/libkern/../../../common/lib/libc/string -I/usr/src/sys/lib
/libkern/../../../common/lib/libc/arch/i386/string -D_FORTIFY_SOURCE=2 -I/usr/sr
c/sys/external/isc/atheros_hal/dist -I/usr/src/sys/external/isc/atheros_hal/ic -
I/usr/src/sys/external/bsd/acpica/dist/include -c /usr/src/sys/dev/acpi/fujhk_ac
pi.c
/usr/src/sys/dev/acpi/fujhk_acpi.c: In function 'fujitsu_hk_event_callback':
/usr/src/sys/dev/acpi/fujhk_acpi.c:262:10: error: 'irb' may be used uninitialized in this function [-Werror=maybe-uninitialized]
index = FUJITSU_HK_IRB_HOTKEY_INDEX(irb);
^
cc1: all warnings being treated as errors
*** Failed target: fujhk_acpi.o
Edit ./sys/kern/core_elf32.c :
# diff -u ./sys/kern/core_elf32.c.orig ./sys/kern/core_elf32.c
--- ./sys/kern/core_elf32.c.orig 2016-08-31 15:24:19.000000000 +1000
+++ ./sys/kern/core_elf32.c 2016-08-31 17:32:59.000000000 +1000
@@ -510,7 +510,7 @@
#else /* COREDUMP */
int
-ELFNAMEEND(coredump)(struct lwp *l, void *cookie)
+ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
{
return ENOSYS;
#
Without that change this error occurred:
# compile G4U-KERNEL/core_elf32.o
/usr/src/obj.i386/tooldir-NetBSD/bin/i486--netbsdelf-gcc -msoft-float -mno-mmx -mno-sse -mno-avx -ffreestanding -fno-zero-initialized-in-bss -g -Os -fstack-protector -Wstack-protector --param ssp-buffer-size=1 -fno-strict-aliasing -fno-common -std=gnu99 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-pointer-sign -Wno-attributes -Wextra -Wno-unused-parameter -Wold-style-definition -Wno-sign-compare -march=i486 -mtune=pentiumpro --sysroot=/usr/src/obj.i386/destdir -Di386 -I. -I/usr/src/sys/../common/include -I/usr/src/sys/arch -I/usr/src/sys -nostdinc -DCHILD_MAX=1024 -DOPEN_MAX=1024 -DMSGBUFSIZE=50000 -DHALT_ON_PANIC -DMAXUSERS=2 -D_KERNEL -D_KERNEL_OPT -std=gnu99 -I/usr/src/sys/lib/libkern/../../../common/lib/libc/quad -I/usr/src/sys/lib/libkern/../../../common/lib/libc/string -I/usr/src/sys/lib/libkern/../../../common/lib/libc/arch
/i386/string -D_FORTIFY_SOURCE=2 -I/usr/src/sys/external/isc/atheros_hal/dist -I/usr/src/sys/external/isc/atheros_hal/ic -I/usr/src/sys/external/bsd/acpica/dist/include -c /usr/src/sys/kern/core_elf32.c
In file included from /usr/src/sys/kern/core_elf32.c:42:0:
/usr/src/sys/kern/core_elf32.c:513:12: error: conflicting types for 'coredump_elf32'
ELFNAMEEND(coredump)(struct lwp *l, void *cookie)
^
/usr/src/sys/sys/cdefs.h:93:23: note: in definition of macro '__CONCAT'
#define __CONCAT(x,y) x ## y
^
/usr/src/sys/sys/exec_elf.h:1029:23: note: in expansion of macro 'CONCAT'
#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
^
/usr/src/sys/kern/core_elf32.c:513:1: note: in expansion of macro 'ELFNAMEEND'
ELFNAMEEND(coredump)(struct lwp *l, void *cookie)
^
In file included from /usr/src/sys/kern/core_elf32.c:58:0:
/usr/src/sys/sys/exec_elf.h:1286:5: note: previous declaration of 'coredump_elf32' was here
int coredump_elf32(struct lwp *, struct coredump_iostate *);
^
*** Failed target: core_elf32.o
>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/51460: Source code bugs
Date: Sat, 3 Sep 2016 21:22:47 +0200
On Sat, Sep 03, 2016 at 04:15:00PM +0000, ray.phillips@gmail.com wrote:
> They're obviously not critical problems since NetBSD/i386 7.0.1 has
> been compiled successfully and released. I suppose the g4u-build
> script must use different compiler settings to have produced these
> errors.
The -Os is likely causing this. This should be fixed (maybe we should
add a ALL-Os kernel config to verify this permanently)
Martin
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/51460: Source code bugs
Date: Sat, 3 Sep 2016 20:23:46 +0000
On Sat, Sep 03, 2016 at 07:25:01PM +0000, Martin Husemann wrote:
> On Sat, Sep 03, 2016 at 04:15:00PM +0000, ray.phillips@gmail.com wrote:
> > They're obviously not critical problems since NetBSD/i386 7.0.1 has
> > been compiled successfully and released. I suppose the g4u-build
> > script must use different compiler settings to have produced these
> > errors.
>
> The -Os is likely causing this. This should be fixed (maybe we should
> add a ALL-Os kernel config to verify this permanently)
The uninitialized warning, certainly. The type error doesn't seem so
likely...
--
David A. Holland
dholland@netbsd.org
From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: re: kern/51460: Source code bugs
Date: Mon, 05 Sep 2016 16:03:42 +1000
> # diff -u ./sys/dev/acpi/fujhk_acpi.c.orig ./sys/dev/acpi/fujhk_acpi.c
> --- ./sys/dev/acpi/fujhk_acpi.c.orig 2016-08-31 21:55:27.000000000 +1000
> +++ ./sys/dev/acpi/fujhk_acpi.c 2016-08-31 22:13:25.000000000 +1000
> @@ -246,6 +246,7 @@
> uint32_t irb;
> int i, index;
>
> + irb = 0; /* make sure irb has been initialized */
> for (i = 0; i < max_irb_buffer_size; i++) {
> if (fujitsu_hk_get_irb(sc, &irb) || irb == 0)
> return;
> #
this is a bug in GCC. i've stopped patching our sources
to build with -O3 / -Os because of these sorts of issues.
eg, i haven't checked, but i fully expect that in the above
code that fujitsu_hk_get_irb(), which is local, always
sets irb if it returns true, but for some reason GCC thinks
it is a problem. i've seen this pattern dozens of times.
i don't agree with Martin - i don't think we should "fix"
these cases, but simply advise not using '-O[3s] -Werror'.
.mrg.
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51460 CVS commit: src/sys/kern
Date: Mon, 5 Sep 2016 17:42:57 +0000
Module Name: src
Committed By: dholland
Date: Mon Sep 5 17:42:57 UTC 2016
Modified Files:
src/sys/kern: core_elf32.c
Log Message:
Build fix for when COREDUMP is turned off, from Ray Phillips in PR 51460.
To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/kern/core_elf32.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.