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


Nathan Sidwell <nathan@acm.org> writes:

> 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()).

You might use the lock just to guard a boolean value that flags
whether the static location is busy or not.  If a thread finds that it
needs to use the static location and it is busy already, it calls
terminate.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:oliva@gnu.org mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



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