This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH:throwing exceptions with no memory


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]