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: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Subject: Re: PATCH:throwing exceptions with no memory
- From: Nathan Sidwell <nathan at acm dot org>
- Date: Tue, 27 Oct 1998 09:11:42 +0000
- CC: egcs-patches at cygnus dot com
- Organization: Computer Science Dept, Bristol University
- References: <363457E8.6617@acm.org> <199810262249.XAA00455@mira.isdn.cs.tu-berlin.de>
Martin von Loewis wrote:
> 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.
Yes, I had thought about that, but wasn't totally happy with such a
solution. If there was such mutex in allocating eh_context, the
following program would deadlock (rather than __terminate()).
thread 1 .. lock foo ... throw (block in new_eh_context)
thread 2 .. throw -> catch ... lock foo (block)
There's no workaround for this in user code (thread 1's throw might be
inside a function and not accessible to the foo locker). Whereas there
is for the patched behaviour.
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
You can up the bandwidth, but you can't up the speed of light
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk