NetBSD Problem Report #52451

From www@NetBSD.org  Tue Aug  1 23:41:16 2017
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 "mail.NetBSD.org CA" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B9A4E7A1F5
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  1 Aug 2017 23:41:16 +0000 (UTC)
Message-Id: <20170801234114.D1A0D7A270@mollari.NetBSD.org>
Date: Tue,  1 Aug 2017 23:41:14 +0000 (UTC)
From: jdbaker@mylinuxisp.com
Reply-To: jdbaker@mylinuxisp.com
To: gnats-bugs@NetBSD.org
Subject: PMC support breaks build of kernels with COPTS=-Os
X-Send-Pr-Version: www-1.0

>Number:         52451
>Category:       port-i386
>Synopsis:       PMC support breaks build of kernels with COPTS=-Os
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-i386-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 01 23:45:00 +0000 2017
>Closed-Date:    Fri Aug 25 07:29:43 +0000 2017
>Last-Modified:  Fri Aug 25 07:29:43 +0000 2017
>Originator:     John D. Baker
>Release:        NetBSD/i386-8.99.1 after 201707121741Z, NetBSD/i386-8.0_BETA after 201708012319Z
>Organization:
>Environment:
NetBSD net4501b.technoskunk.fur 8.0_BETA NetBSD 8.0_BETA (NET4501_JDB) #70: Wed Jul 26 19:38:45 CDT 2017  sysop@x3650.technoskunk.fur:/r1/build/netbsd-8/obj/i386/sys/arch/i386/compile/NET4501_JDB i386

>Description:
Kernel configs like "NET4501" routinely include:

   makeoptions "COPTS=-Os"

This causes GCC to emit warnings (treated as errors) if it thinks a
variable might be used uninitialized.  For example, the following:

#   compile  NET4501_JDB/pmc.o
/r1/build/current/tools/amd64/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 --sysroot=/r1/build/current/DEST/i386 -Di386 -I. -I/x/current/src/sys/external/bsd/acpica/dist -I/x/current/src/sys/../common/lib/libx86emu -I/x/current/src/sys/../common/include -I/x/current/src/sys/arch -I/x/current/src/sys -nostdinc -DTIMER_FREQ=1189200 -D_KERNEL -D_KERNEL_OPT -std=gnu99 -I/x/current/src/sys/lib/libkern/../../../common/lib/libc/quad -I/x/current/src/sys/lib/libkern/../../../common/lib/libc/string -I/x/current/src/sys/lib/l
 ibkern/../../../common/lib/libc/arch/i386/string -D_FORTIFY_SOURCE=2 -I/x/current/src/sys/dist/pf -c /x/current/src/sys/arch/x86/x86/pmc.c -o pmc.o
/x/current/src/sys/arch/x86/x86/pmc.c: In function 'pmc_nmi':
/x/current/src/sys/arch/x86/x86/pmc.c:168:2: error: 'pmc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  wrmsr(pmc->ctrmsr, pmc->ctrinitval);
  ^

>How-To-Repeat:
Attempt to build NET4501 kernel on -current after 201707121741Z or
on 8.0_BETA after 201708012319Z.
>Fix:
Workaround:

Would the following patch be appropriate for appeasing GCC?

+Index: sys/arch/x86/x86/pmc.c
+===================================================================
+RCS file: /cvsroot/src/sys/arch/x86/x86/pmc.c,v
+retrieving revision 1.10
+diff -u -p -r1.10 pmc.c
+--- sys/arch/x86/x86/pmc.c	12 Jul 2017 17:33:29 -0000	1.10
++++ sys/arch/x86/x86/pmc.c	13 Jul 2017 19:08:13 -0000
+@@ -138,7 +138,7 @@ static int
+ pmc_nmi(const struct trapframe *tf, void *dummy)
+ {
+ 	struct cpu_info *ci = curcpu();
+-	pmc_state_t *pmc;
++	pmc_state_t *pmc = (pmc_state_t *)NULL;
+ 	pmc_cpu_t *cpu;
+ 	uint64_t ctr;
+ 	size_t i;

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: maxv@NetBSD.org
State-Changed-When: Mon, 07 Aug 2017 17:32:09 +0000
State-Changed-Why:
I committed your fix, thanks for the report.


From: "Maxime Villard" <maxv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52451 CVS commit: src/sys/arch/x86/x86
Date: Mon, 7 Aug 2017 17:31:11 +0000

 Module Name:	src
 Committed By:	maxv
 Date:		Mon Aug  7 17:31:11 UTC 2017

 Modified Files:
 	src/sys/arch/x86/x86: pmc.c

 Log Message:
 Fix GCC warning on NET4501, PR/52451.


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/x86/pmc.c

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

From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: port-i386-maintainer@netbsd.org, maxv@NetBSD.org
Subject: Re: port-i386/52451 (PMC support breaks build of kernels with
 COPTS=-Os)
Date: Mon, 7 Aug 2017 13:15:21 -0500 (CDT)

 On Mon, 7 Aug 2017, maxv@NetBSD.org wrote:
 > State-Changed-From-To: open->closed
 > State-Changed-By: maxv@NetBSD.org
 > State-Changed-When: Mon, 07 Aug 2017 17:32:09 +0000
 > State-Changed-Why:
 > I committed your fix, thanks for the report.

 Since the code that breaks NET4501 was pulled up to netbsd-8, the
 fix also needs to be pulled up to netbsd-8.

 This PR should remain open in "needs-pullups" or "pending-pullups"
 state as appropriate.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-i386/52451 (PMC support breaks build of kernels with
 COPTS=-Os) (fwd)
Date: Tue, 22 Aug 2017 01:31:40 -0500 (CDT)

 Re-sending so perhaps someone sees it.

 ---------- Forwarded message ----------
 Date: Mon, 7 Aug 2017 13:15:21 -0500 (CDT)
 From: John D. Baker <jdbaker@david.technoskunk.fur>
 To: gnats-bugs@NetBSD.org
 Cc: port-i386-maintainer@netbsd.org, maxv@NetBSD.org
 Subject: Re: port-i386/52451 (PMC support breaks build of kernels with
     COPTS=-Os)

 On Mon, 7 Aug 2017, maxv@NetBSD.org wrote:
 > State-Changed-From-To: open->closed
 > State-Changed-By: maxv@NetBSD.org
 > State-Changed-When: Mon, 07 Aug 2017 17:32:09 +0000
 > State-Changed-Why:
 > I committed your fix, thanks for the report.

 Since the code that breaks NET4501 was pulled up to netbsd-8, the
 fix also needs to be pulled up to netbsd-8.

 This PR should remain open in "needs-pullups" or "pending-pullups"
 state as appropriate.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

State-Changed-From-To: closed->pending-pullups
State-Changed-By: jdolecek@NetBSD.org
State-Changed-When: Tue, 22 Aug 2017 07:01:18 +0000
State-Changed-Why:
Requested pullup to netbsd-8.


From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52451 CVS commit: [netbsd-8] src/sys/arch/x86/x86
Date: Fri, 25 Aug 2017 05:42:55 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Fri Aug 25 05:42:55 UTC 2017

 Modified Files:
 	src/sys/arch/x86/x86 [netbsd-8]: pmc.c

 Log Message:
 Pull up following revision(s) (requested by jdolecek in ticket #225):
 	sys/arch/x86/x86/pmc.c: revision 1.11
 Fix GCC warning on NET4501, PR/52451.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/arch/x86/x86/pmc.c

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

State-Changed-From-To: pending-pullups->closed
State-Changed-By: jdolecek@NetBSD.org
State-Changed-When: Fri, 25 Aug 2017 07:29:43 +0000
State-Changed-Why:
Pullup to netbsd-8 done now, too. Thanks for report.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.