This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH:throwing exceptions with no memory
- To: nathan at acm dot org
- Subject: Re: PATCH:throwing exceptions with no memory
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Mon, 26 Oct 1998 23:49:46 +0100
- CC: egcs-patches at cygnus dot com
- References: <363457E8.6617@acm.org>
> This means that a single threaded application can't die here, but a
> multi threaded application could, if two threads throw exceptions with
> malloc failing. The only way to fix this properly is in the thread
> creation to allocate the eh_context.
There is another way: Put a mutex around this struct, and release the
lock only if the exception is caught for good. Another thread
detecting memory shortage will block until the first thread has
finished (perhaps after returning some memory). Of course, we can't be
sure that the threads library won't attempt to allocate memory, so we
might be better off leaving it that to applications.
I like this patch (as if that matters :-)
Martin