From owner-freebsd-bugs Sun Feb 1 23:46:22 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA18341 for freebsd-bugs-outgoing; Sun, 1 Feb 1998 23:46:22 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA18335 for ; Sun, 1 Feb 1998 23:46:21 -0800 (PST) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id XAA21078; Sun, 1 Feb 1998 23:18:59 -0800 (PST) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma021074; Sun Feb 1 23:18:40 1998 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id XAA05015; Sun, 1 Feb 1998 23:18:40 -0800 (PST) From: Archie Cobbs Message-Id: <199802020718.XAA05015@bubba.whistle.com> Subject: Re: bin/5604: memory leak and other bugs in setenv(3) In-Reply-To: from Jonathan Hanna at "Feb 1, 98 06:20:44 pm" To: pangolin@rogers.wave.ca Date: Sun, 1 Feb 1998 23:18:40 -0800 (PST) Cc: imdave@mcs.net, freebsd-bugs@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org X-To-Unsubscribe: mail to majordomo@FreeBSD.org "unsubscribe freebsd-bugs" Jonathan Hanna writes: > > On 02-Feb-98 Jonathan Hanna wrote: > > > > On 01-Feb-98 Archie Cobbs wrote: > >> Dave Bodenstab writes: > >>>... Unless setenv > >>> were changed to keep a record of which environ[] elements had been > >>> malloc'ed by a previous call to setenv, there is no way to know if > >>> it is OK to call free(). Your fix to setenv makes an illegal call > >>> to free -- change your test program to: > >> > >> Yes.. I didn't think of this until after submitting the bug. I think > >> the only way to stop the leak is by keeping a list of the actual pointers > >> returned from calls to malloc() and realloc() (rather than a binary > >> array, because user code can modify environ[x]). > > > > Is there a problem with just checking that the address is higher up the stack? > > For threaded environments is there a reliable way of determining that > > an address is on the original stack? If not, should malloc have an entry > > point to ask it if it owns something? > > Oops, ignore the stack nonsense, and even malloc cannot help. Nasty. I like the idea of being able to ask the malloc() code if a pointer is valid to call free() with... might have other uses. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com