Re: [c++-pthreads] Restating the Jason model
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] Restating the Jason model



Jason Merrill wrote:

On Tue, 13 Jan 2004 07:47:17 -0500, Dave Butenhof <David.Butenhof@xxxxxx> wrote:
>
Cancellation should NOT be disabled in destructors? Did you mean to say
that?

Yes. Destructors can be run under two different situations: 1) when the object goes out of scope during normal execution; 2) when unwinding the stack during exception handling.

In #1, an exception thrown out of a destructor is propagated normally.  In
the #2, it causes a call to terminate().  So we need to suppress
cancellation for #2, but not (necessarily) #1.

It is true that an exception escaping from a destructor will not trigger immediate program termination when the program/thread in question is not unwinding; however, that doesn't mean there's nothing to worry about. The most likely symptom is a resource leak; in a multi-threaded environment, that could mean a deadlock.

- Wil