From nobody@FreeBSD.org  Fri Sep 14 08:02:38 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 1280B106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 Sep 2012 08:02:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id D9A4C8FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 Sep 2012 08:02:37 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q8E82bSl045453
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 Sep 2012 08:02:37 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q8E82bkx045452;
	Fri, 14 Sep 2012 08:02:37 GMT
	(envelope-from nobody)
Message-Id: <201209140802.q8E82bkx045452@red.freebsd.org>
Date: Fri, 14 Sep 2012 08:02:37 GMT
From: Erik Cederstrand <erik@cederstrand.dk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Memory leak in /bin/df
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         171634
>Category:       bin
>Synopsis:       Memory leak in /bin/df
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 14 08:10:08 UTC 2012
>Closed-Date:    Sun Sep 16 16:09:08 UTC 2012
>Last-Modified:  Sun Sep 16 16:10:11 UTC 2012
>Originator:     Erik Cederstrand
>Release:        HEAD
>Organization:
>Environment:
>Description:
There seems to be a memory leak in /bin/df. See report on http://scan.freebsd.your.org/freebsd-head/bin.df/2012-09-12-amd64/report-WwB2qk.html#EndPath


>How-To-Repeat:

>Fix:
It seems

  free(mntbuf);

should be added on line 292.

>Release-Note:
>Audit-Trail:

From: Xin Li <delphij@delphij.net>
To: Erik Cederstrand <erik@cederstrand.dk>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/171634: Memory leak in /bin/df
Date: Fri, 14 Sep 2012 01:14:37 -0700

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA256
 
 I believe this is a false positive.  There is no reason to release
 memory right before quit, it's a waste of time and OS reclaims the
 memory regardless.
 
 Cheers,
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
 
 iQEcBAEBCAAGBQJQUudtAAoJEG80Jeu8UPuzl48IALp9QNVmLeKptUTUfmDp3dzf
 numNhWWxRG60ApQ4Jjr1uDUGXw4rqis6SJLdlla4fOeZwJo7MPBC/vKXc3NA8iGx
 qAnosp8tOJJYPS9BylPrRn9oGprfTvgMdvk99hFv60xTgrSLuiIVU1iMSE/mK08e
 /L+zuAEHWHW2r0TNx/frAGl7YpjX6R3jTZqBbiCi40CYW3Wyo7POTgd1kLpjdQcn
 IKVtJ1fzUPCEmZs+l6yOQTl9mthwtrNL8e5S7ZUSolUWxU5uaM4kZeP9Y8AQ+bck
 QTqLR/yoWZkImHYDHt1Mzo6WwtL59Sc97U5m1crkWInl3eh3ts/ET+ECdHwWEW0=
 =aKzf
 -----END PGP SIGNATURE-----

From: Erik Cederstrand <erik@cederstrand.dk>
To: d@delphij.net
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/171634: Memory leak in /bin/df
Date: Fri, 14 Sep 2012 13:34:20 +0200

 Hello Xin Li,
 
 Den 14/09/2012 kl. 10.14 skrev Xin Li <delphij@delphij.net>:
 
 > I believe this is a false positive.  There is no reason to release
 > memory right before quit, it's a waste of time and OS reclaims the
 > memory regardless.
 
 I raised question this on the Clang list. Joerg Sonnenberger replied =
 this:
 
   I wouldn't classify it as false positive. E.g. it is perfectly sane=20
   to redefine main as macro to use in a larger program.
 
 It's a one-liner and it's done anyway, albeit implicitly, so maybe it's =
 not too bad to make the free() explicit?
 
 Erik=
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Fri Sep 14 13:44:45 UTC 2012 
Responsible-Changed-Why:  
I'll take it; it doesn't take much time and it helps tools 

http://www.freebsd.org/cgi/query-pr.cgi?pr=171634 
State-Changed-From-To: open->analyzed 
State-Changed-By: eadler 
State-Changed-When: Fri Sep 14 14:42:59 UTC 2012 
State-Changed-Why:  
awaiting approval 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/171634: commit references a PR
Date: Fri, 14 Sep 2012 23:47:36 +0000 (UTC)

 Author: eadler
 Date: Fri Sep 14 23:47:23 2012
 New Revision: 240527
 URL: http://svn.freebsd.org/changeset/base/240527
 
 Log:
   Free memory before exiting in order to
   help tools understand that we're not leaking it.
   
   PR:		bin/171634
   Submitted by:	Erik Cederstrand <erik@cederstrand.dk>
   Approved by:	cperciva
   MFC after:	3 days
 
 Modified:
   head/bin/df/df.c
 
 Modified: head/bin/df/df.c
 ==============================================================================
 --- head/bin/df/df.c	Fri Sep 14 22:53:47 2012	(r240526)
 +++ head/bin/df/df.c	Fri Sep 14 23:47:23 2012	(r240527)
 @@ -290,6 +290,7 @@ main(int argc, char *argv[])
  			prtstat(&mntbuf[i], &maxwidths);
  	if (cflag)
  		prtstat(&totalbuf, &maxwidths);
 +	free(mntbuf);
  	return (rv);
  }
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: eadler 
State-Changed-When: Fri Sep 14 23:55:05 UTC 2012 
State-Changed-Why:  
committed in r240527 

http://www.freebsd.org/cgi/query-pr.cgi?pr=171634 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Sun Sep 16 16:09:06 UTC 2012 
State-Changed-Why:  
this free is wrong (the pointer can point 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/171634: commit references a PR
Date: Sun, 16 Sep 2012 16:08:33 +0000 (UTC)

 Author: eadler
 Date: Sun Sep 16 16:08:20 2012
 New Revision: 240565
 URL: http://svn.freebsd.org/changeset/base/240565
 
 Log:
   Revert 240527:
   	mntbuf can poit to memory allocated by getmntinfo(3) which can't be freed
   
   PR:		bin/171634
   Approved by:	cperciva (implicit)
 
 Modified:
   head/bin/df/df.c
 
 Modified: head/bin/df/df.c
 ==============================================================================
 --- head/bin/df/df.c	Sun Sep 16 15:35:05 2012	(r240564)
 +++ head/bin/df/df.c	Sun Sep 16 16:08:20 2012	(r240565)
 @@ -290,7 +290,6 @@ main(int argc, char *argv[])
  			prtstat(&mntbuf[i], &maxwidths);
  	if (cflag)
  		prtstat(&totalbuf, &maxwidths);
 -	free(mntbuf);
  	return (rv);
  }
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
