Date: Fri, 25 Jul 2003 20:29:46 +0200 From: Steve O'Hara-Smith <steve@sohara.org> To: Peter Jeremy <peter.jeremy@alcatel.com.au> Cc: freebsd-stable@freebsd.org Subject: Re: malloc does not return null when out of memory Message-ID: <20030725202946.0e554369.steve@sohara.org> In-Reply-To: <20030724213707.GU430@gsmx07.alcatel.com.au> References: <20030723173427.GA72876@vmunix.com> <20030723173427.GA72876@vmunix.com> <5.2.0.9.0.20030723234250.052821e8@192.168.0.12> <20030724070936.GA16762@rot13.obsecurity.org> <3F1FF81F.5050701@mac.com> <20030724164522.GA39964@pit.databus.com> <20030724201702.6667b707.steve@sohara.org> <20030724213707.GU430@gsmx07.alcatel.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 25 Jul 2003 07:37:07 +1000 Peter Jeremy <peter.jeremy@alcatel.com.au> wrote: PJ> I'd suggest adding code in the "malloc_overcommit" path to touch stack PJ> that is likely to be used, close to the top of {m,c,re}alloc(). Sounds like a good move. PJ> There's a gcc-specific extension "__builtin_frame_address()" that will PJ> let you do this. This ensures that the stack pages you need are Urk - someone who understands the layout of the stack and can estimate the probable use had better look at doing that if it's going to happen. As for freeing the already allocated memory - what a good idea :) PJ> present before you try to sbrk() the data. There may still be other PJ> corner cases I've missed. PJ> PJ> Cleanly recovering in all cases when there is no additional memory PJ> available is a very hard problem. Most of the suggested fixes This is true - OTOH the OP would probably be much happier if malloc could be made to return NULL nearly always when memory can't be allocated, with a small probability of crashing. It looks like between us we might manage to produce a patch that will do that much. -- C:>WIN | Directable Mirrors The computer obeys and wins. |A Better Way To Focus The Sun You lose and Bill collects. | licenses available - see: | http://www.sohara.org/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030725202946.0e554369.steve>