Date: Mon, 23 Apr 2012 13:48:52 -0400 From: Andrew Boyer <aboyer@averesystems.com> To: Dimitry Andric <dim@FreeBSD.org> Cc: Current FreeBSD <freebsd-current@freebsd.org>, Greg Bednarek <gbednarek@averesystems.com> Subject: Re: Memory leak in authunix_create_default()... Message-ID: <D0291F2C-1864-44DC-87EA-591A6D9B4501@averesystems.com> In-Reply-To: <4F9594EA.3050108@FreeBSD.org> References: <3C479FEC-971A-4099-9CA5-B522574BE763@averesystems.com> <A36F8327-BD58-4904-99C7-FEB893FE3561@averesystems.com> <4F9594EA.3050108@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail-7-413847496 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Apr 23, 2012, at 1:44 PM, Dimitry Andric wrote: > On 2012-04-23 19:31, Andrew Boyer wrote: >> Begin forwarded message: >>=20 >>> From: Greg Bednarek <gbednarek@averesystems.com> >>> Date: April 16, 2012 10:54:33 AM EDT >>> To: freebsd-current@freebsd.org >>> Cc: Andrew Boyer <aboyer@averesystems.com> >>> Subject: Memory leak in authunix_create_default()... >>>=20 >>>=20 >>> Please see the attached patch for a proposed fix for a memory leak = in authunix_create_default(). >>>=20 >>> The leak appears to have been introduced 6/19/2009 in Revision = 194494 of lib/libc/rpc/auth_unix.c >>>=20 >>> As you can see form the patch, the fix is very simple. The issue was = discovered when tracking down some rather drastic increases in = application memory footprint during certain types of workloads, and was = eventually traced it to this (apparently) not very heavily used path in = libc. >>>=20 >>> I would appreciate hearing any comments/concerns with the proposed = fix. >=20 > Hi, >=20 > The patch itself seems to have gone missing? Trying again... --Apple-Mail-7-413847496 Content-Disposition: attachment; filename=auth_unix.diff Content-Type: application/octet-stream; name="auth_unix.diff" Content-Transfer-Encoding: 7bit Index: lib/libc/rpc/auth_unix.c =================================================================== --- lib/libc/rpc/auth_unix.c (revision 234224) +++ lib/libc/rpc/auth_unix.c (working copy) @@ -185,6 +185,7 @@ AUTH * authunix_create_default() { + AUTH *auth; int ngids; long ngids_max; char machname[MAXHOSTNAMELEN + 1]; @@ -207,8 +208,10 @@ if (ngids > NGRPS) ngids = NGRPS; /* XXX: interface problem; those should all have been unsigned */ - return (authunix_create(machname, (int)uid, (int)gid, ngids, - (int *)gids)); + auth = authunix_create(machname, (int)uid, (int)gid, ngids, + (int *)gids); + free(gids); + return (auth); } /* --Apple-Mail-7-413847496 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Index: lib/libc/rpc/auth_unix.c =================================================================== --- lib/libc/rpc/auth_unix.c (revision 234224) +++ lib/libc/rpc/auth_unix.c (working copy) @@ -185,6 +185,7 @@ AUTH * authunix_create_default() { + AUTH *auth; int ngids; long ngids_max; char machname[MAXHOSTNAMELEN + 1]; @@ -207,8 +208,10 @@ if (ngids > NGRPS) ngids = NGRPS; /* XXX: interface problem; those should all have been unsigned */ - return (authunix_create(machname, (int)uid, (int)gid, ngids, - (int *)gids)); + auth = authunix_create(machname, (int)uid, (int)gid, ngids, + (int *)gids); + free(gids); + return (auth); } /* -------------------------------------------------- Andrew Boyer aboyer@averesystems.com --Apple-Mail-7-413847496--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D0291F2C-1864-44DC-87EA-591A6D9B4501>