NetBSD Problem Report #39835

From hf@spg.tu-darmstadt.de  Thu Oct 30 13:26:13 2008
Return-Path: <hf@spg.tu-darmstadt.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 9BE9E63BCFC
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 30 Oct 2008 13:26:13 +0000 (UTC)
Message-Id: <200810301326.m9UDQ612013529@Hochstuhl.nt.e-technik.tu-darmstadt.de>
Date: Thu, 30 Oct 2008 14:26:06 +0100 (CET)
From: Hauke Fath <hf@spg.tu-darmstadt.de>
Reply-To: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@gnats.NetBSD.org
Cc: Hauke Fath <hf@spg.tu-darmstadt.de>
Subject: 'Uninitialized var in altq_subr.c' build failure
X-Send-Pr-Version: 3.95

>Number:         39835
>Category:       kern
>Synopsis:       'Uninitialized var in altq_subr.c' build failure
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 30 13:30:01 +0000 2008
>Closed-Date:    Mon Dec 01 14:04:54 +0000 2008
>Last-Modified:  Mon Dec 01 14:04:54 +0000 2008
>Originator:     Hauke Fath <hf@spg.tu-darmstadt.de>
>Release:        NetBSD 4.99.73
>Organization:

>Environment:


System: NetBSD 4.99.73 sparc cross-build
Architecture: sparc
Machine: sparc
>Description:

	Compiling an altq enabled -current kernel gives me

#   compile  PIZZA_PF/altq_wfq.o
/u/netbsd-builds/developer/sparc/tools/bin/sparc--netbsdelf-gcc -mno-fpu -ffreestanding -fno-zero-initialized-in-bss -mcpu
--- altq_subr.o ---
cc1: warnings being treated as errors
/public/netbsd-developer/sys/altq/altq_subr.c: In function 'read_machclk':
/public/netbsd-developer/sys/altq/altq_subr.c:826: warning: 'val' may be used uninitialized in this function


	Looking at the source, gcc is right:


1.16         (peter    12-Oct-06): u_int64_t
1.16         (peter    12-Oct-06): read_machclk(void)
1.1          (thorpej  14-Dec-00): {
1.16         (peter    12-Oct-06):      u_int64_t val;
1.16         (peter    12-Oct-06):
1.16         (peter    12-Oct-06):      if (machclk_usepcc) {
1.25         (ad       10-May-08): #ifdef __HAVE_CPU_COUNTER
1.25         (ad       10-May-08):              return cpu_counter();
1.16         (peter    12-Oct-06): #endif
1.1          (thorpej  14-Dec-00):      } else {
1.16         (peter    12-Oct-06):              struct timeval tv;
1.16         (peter    12-Oct-06):
1.16         (peter    12-Oct-06):              microtime(&tv);
1.16         (peter    12-Oct-06):              val = (((u_int64_t)(tv.tv_sec - boottime.tv_sec) * 1000000
1.16         (peter    12-Oct-06):                  + tv.tv_usec) << MACHCLK_SHIFT);
1.1          (thorpej  14-Dec-00):      }
1.16         (peter    12-Oct-06):      return (val);


>How-To-Repeat:

	(Cross-)build.sh a sparc kernel from -current sources.

>Fix:

	I am tempted to slip in a 'val = 0', but am not sure that this
	is the intended return value for 'if (machclk_usepcc)' and
	undefined __HAVE_CPU_COUNTER? Someone who actually knows the
	code should look into this.

	See also
	<http://mail-index.netbsd.org/tech-kern/2008/10/27/msg003274.html> ff.

>Release-Note:

>Audit-Trail:
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org
Subject: Re: kern/39835: 'Uninitialized var in altq_subr.c' build failure
Date: Thu, 20 Nov 2008 17:24:11 +0100

 At 13:30 Uhr +0000 30.10.2008, Hauke Fath wrote:
 >#   compile  PIZZA_PF/altq_wfq.o
 >/u/netbsd-builds/developer/sparc/tools/bin/sparc--netbsdelf-gcc 
 >-mno-fpu -ffreestanding -fno-zero-initialized-in-bss -mcpu
 >--- altq_subr.o ---
 >cc1: warnings being treated as errors
 >/public/netbsd-developer/sys/altq/altq_subr.c: In function 'read_machclk':
 >/public/netbsd-developer/sys/altq/altq_subr.c:826: warning: 'val' 
 >may be used uninitialized in this function

 Obviously, this spilled over to netbsd-5.

 	hauke

 -- 
       The ASCII Ribbon Campaign                    Hauke Fath
 ()     No HTML/RTF in email            Institut für Nachrichtentechnik
 /\     No Word docs in email                     TU Darmstadt
       Respect for open standards              Ruf +49-6151-16-3281

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, hf@spg.tu-darmstadt.de,
        tsutsui@ceres.dti.ne.jp
Subject: Re: kern/39835: 'Uninitialized var in altq_subr.c' build failure
Date: Fri, 21 Nov 2008 01:47:42 +0900

 machclk_usepcc seems to be set only #ifdef __HAVE_CPU_COUNTER case.
 (I'm not sure why it isn't static though)

 Maybe whole if clause should be wrapped with the #ifdef:
 ---
 	u_int64_t val;

 #ifdef __HAVE_CPU_COUNTER
 	if (machclk_usepcc) {
 		return cpu_counter();
 	} else
 #endif
 	{
 		struct timeval tv;
 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39835 CVS commit: src/sys/altq
Date: Tue, 25 Nov 2008 15:59:11 +0000 (UTC)

 Module Name:	src
 Committed By:	tsutsui
 Date:		Tue Nov 25 15:59:11 UTC 2008

 Modified Files:
 	src/sys/altq: altq_subr.c altq_var.h

 Log Message:
 In machclk functions always emulate 1GHz counter using nanotime(9)
 since it has enough resolution via timecounter(9).
 Using machine dependent cpu_counter() is not MP safe
 and it won't work even on UP with Speedstep etc.

 No particular comment on tech-kern, and also closes PR kern/39835.


 To generate a diff of this commit:
 cvs rdiff -r1.25 -r1.26 src/sys/altq/altq_subr.c
 cvs rdiff -r1.11 -r1.12 src/sys/altq/altq_var.h

 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: 
Subject: Re: kern/39835
Date: Wed, 26 Nov 2008 06:54:36 -0600 (CST)

 Please pull up to netbsd-5?

 Thanks.

 -- 
 John D. Baker, KN5UKS                    NetBSD     Darwin/MacOS X
 jdbaker[snail]mylinuxisp[flyspeck]com         OpenBSD            FreeBSD
 BSD -- It just sits there and _works_!
 GPG fingerprint:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

Responsible-Changed-From-To: kern-bug-people->tsutsui
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Wed, 26 Nov 2008 22:07:35 +0900
Responsible-Changed-Why:
I committed changes


State-Changed-From-To: open->feedback
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Wed, 26 Nov 2008 22:07:35 +0900
State-Changed-Why:
Could you test the latest altq_subr.c and altq_var.h?


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
        hf@spg.tu-darmstadt.de, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/39835
Date: Wed, 26 Nov 2008 22:05:51 +0900

 jdbaker@mylinuxisp.com wrote:

 >  Please pull up to netbsd-5?

 Are you using ALTQ on your system?

 I'd like to see if it won't break anything before pullup.
 ---
 Izumi Tsutsui

From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39835 CVS commit: [netbsd-5] src/sys/altq
Date: Mon,  1 Dec 2008 00:55:55 +0000 (UTC)

 Module Name:	src
 Committed By:	snj
 Date:		Mon Dec  1 00:55:55 UTC 2008

 Modified Files:
 	src/sys/altq [netbsd-5]: altq_subr.c altq_var.h

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #152):
 	sys/altq/altq_subr.c: revision 1.26
 	sys/altq/altq_var.h: revision 1.12
 In machclk functions always emulate 1GHz counter using nanotime(9)
 since it has enough resolution via timecounter(9).
 Using machine dependent cpu_counter() is not MP safe
 and it won't work even on UP with Speedstep etc.
 No particular comment on tech-kern, and also closes PR kern/39835.


 To generate a diff of this commit:
 cvs rdiff -r1.25 -r1.25.8.1 src/sys/altq/altq_subr.c
 cvs rdiff -r1.11 -r1.11.44.1 src/sys/altq/altq_var.h

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

State-Changed-From-To: feedback->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Mon, 01 Dec 2008 23:04:54 +0900
State-Changed-Why:
Fixed and pulled up to netbsd-5.


>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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.