PATCH:throwing exceptions with no memory

Nathan Sidwell
Tue Oct 27 01:15:00 GMT 1998

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.

Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light

More information about the Gcc-patches mailing list