Restating the Jason model
David Abrahams
dave at boost-consulting.com
Sat Jan 17 00:32:24 UTC 2004
Wil Evers <wil at bogo.xs4all.nl> writes:
> Jason Merrill wrote:
>
>> On Tue, 13 Jan 2004 07:47:17 -0500, Dave Butenhof <David.Butenhof at hp.com> 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;
Yes, but it could be arbitrarily bad. This is really the same point
I've been making from the beginning: functions which are assumed not
to throw can't suddenly start throwing; it's just as hard to manage
that as to manage asynchronous cancellations. Everybody expects
destructors not to throw.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the c++-pthreads
mailing list