From nobody@FreeBSD.org  Thu Oct 20 15:19:58 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 329E616A420
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 20 Oct 2005 15:19:58 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 771C143D6A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 20 Oct 2005 15:19:57 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j9KFJvxL050380
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 20 Oct 2005 15:19:57 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j9KFJvd5050379;
	Thu, 20 Oct 2005 15:19:57 GMT
	(envelope-from nobody)
Message-Id: <200510201519.j9KFJvd5050379@www.freebsd.org>
Date: Thu, 20 Oct 2005 15:19:57 GMT
From: Bradley T Hughes <bhughes@trolltech.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: most calls to malloc(3) generate warnings in valgrind
X-Send-Pr-Version: www-2.3

>Number:         87729
>Category:       kern
>Synopsis:       [libc] [patch] most calls to malloc(3) generate warnings in valgrind
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    brucec
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 20 15:20:18 GMT 2005
>Closed-Date:    Wed Feb 23 21:58:16 UTC 2011
>Last-Modified:  Wed Feb 23 21:58:16 UTC 2011
>Originator:     Bradley T Hughes
>Release:        6.0-RC1
>Organization:
Trolltech AS
>Environment:
FreeBSD reticent.troll.no 6.0-RC1 FreeBSD 6.0-RC1 #28: Mon Oct 17 08:46:08 CEST 2005     root@reticent.troll.no:/usr/obj/usr/src/sys/RETICENT  i386
>Description:
              When using valgrind from ports to debug a program, most calls to malloc(3) generate a warning about a comparison depending on uninitialized values.
>How-To-Repeat:
              Run valgrind on /bin/ls
>Fix:
              Apply the attached patch to src/lib/libc/stdlib/malloc.c, it makes sure that all bits in the pginfo.bits bitfield are initialized.
>Release-Note:
>Audit-Trail:

From: Bradley T Hughes <bhughes@trolltech.com>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc:  
Subject: Re: bin/87729: most calls to malloc(3) generate warnings in valgrind
Date: Thu, 20 Oct 2005 17:24:15 +0200

 This is a multi-part message in MIME format.
 --------------070208000107050800030908
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 FreeBSD-gnats-submit@FreeBSD.org wrote:
 > Thank you very much for your problem report.
 > It has the internal identification `bin/87729'.
 > The individual assigned to look at your
 > report is: freebsd-bugs. 
 > 
 > You can access the state of your problem report at any time
 > via this link:
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=87729
 > 
 > 
 >>Category:       bin
 >>Responsible:    freebsd-bugs
 >>Synopsis:       most calls to malloc(3) generate warnings in valgrind
 >>Arrival-Date:   Thu Oct 20 15:20:18 GMT 2005
 
 Here is the patch that I couldn't attach when using the web form.
 
 -- 
 Bradley T. Hughes - bhughes at trolltech.com
 Trolltech AS - Waldemar Thranes gt. 98 N-0175 Oslo, Norway
 
 --------------070208000107050800030908
 Content-Type: text/plain;
  name="malloc.c.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="malloc.c.diff"
 
 --- malloc.c	Wed Oct 19 13:30:01 2005
 +++ malloc.c~	Wed Oct 19 13:29:01 2005
 @@ -635,8 +635,11 @@
      for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)
  	bp->bits[i / MALLOC_BITS] = ~0;
  
 -    for(; i < k; i++)
 -        bp->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
 +    if (i < k) {
 +        bp->bits[i/MALLOC_BITS] = 0;
 +        for(; i < k; i++)
 +            bp->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
 +    }
  
      if (bp == bp->page) {
  	/* Mark the ones we stole for ourselves */
 
 --------------070208000107050800030908--
Responsible-Changed-From-To: freebsd-bugs->phk 
Responsible-Changed-By: kris 
Responsible-Changed-When: Fri Oct 21 20:33:17 GMT 2005 
Responsible-Changed-Why:  
Assign to malloc author 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87729 

From: Mikhail Teterin <mi+kde@aldan.algebra.com>
To: bug-followup@freebsd.org, bhughes@trolltech.com
Cc:  
Subject: Re: bin/87729: most calls to malloc(3) generate warnings in valgrind
Date: Fri, 20 Jul 2007 13:33:46 -0400

 I too am experiencing this problem -- trying to debug something is rather 
 difficult, when valgrind keeps reporting errors in libc. Is the problem 
 real -- can the values reported as uninitialized really be anything but zero?
 
 If the patch is right way to fix it, what's holding it up?
 
 It will soon be two years since the PR was created...
 
 	-mi
State-Changed-From-To: open->closed 
State-Changed-By: brucec 
State-Changed-When: Wed Feb 23 21:55:25 UTC 2011 
State-Changed-Why:  
This appears to have been fixed, possibly due to the malloc implementation 
being changed in FreeBSD 7.0. 


Responsible-Changed-From-To: phk->brucec 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Wed Feb 23 21:55:25 UTC 2011 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87729 
>Unformatted:
