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


> 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


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