Date: Fri, 7 Aug 1998 01:46:10 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: nate@mt.sri.com (Nate Williams) Cc: dg@root.com, narvi@haldjas.folklore.ee, bde@zeta.org.au, freebsd@xaa.iae.nl, freebsd-current@FreeBSD.ORG Subject: Re: memory leaks in libc Message-ID: <199808070146.SAA25783@usr06.primenet.com> In-Reply-To: <199808061447.IAA12240@mt.sri.com> from "Nate Williams" at Aug 6, 98 08:47:45 am
next in thread | previous in thread | raw e-mail | index | archive | help
> > The problem with fixing setenv() is that you don't know if a pointer > > was malloced, allocated from the env area above the stack, points to > > read-only text, points to a static data buffer, etc. There really is > > no way to know for sure, so you can't free the memory. [ ... ] > > You can know if you malloced it in a previous call to putenv() or setenv(). [ ... ] > > Perhaps Bruce is suggesting that a seperate array be allocated to keep > > track of whether or not an env pointer was malloced? This would be very > > costly and, IMO, not worth it considering how rarely memory is lost by > > not freeing previously malloced strings. > > Very costly? Could you do almost all of it in the userland libraries, > and would be pretty cost-free, especially considering it would only have > much effect if the user did lots of environment allocations? The easiest thing to do would be to, in crt0.o, set another envp (__envp?) to point to the the original envp. If they are not equal, then you realloc the space. Frankly, I'd rather just hang the think of the proc struct. It's the non-opaque accesses and the execve(2) insistance on an envp in a non-opaque format that screw you. You can still implement it, but you have to tread a fine line to do it. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808070146.SAA25783>