[c++-pthreads] Re: thread-safety definition
Wil Evers
wil at bogo.xs4all.nl
Fri Jan 9 06:01:31 UTC 2004
Dave Butenhof wrote:
> Wil Evers wrote:
>
>> Dave Butenhof wrote:
>>
>>> If cancel is implemented completely as a "full stature" C++
>>> exception, and none of the "exception safe" code does anything silly
>>> like "catch(...)" without a re-throw, then, yes, it's likely to be
>>> reasonably cancel-safe.
>>
>> A catch(...) without a re-throw isn't necessarily a silly thing to do,
>> especially in a destructor. Sometimes, the only alternative is to
>> risk a call to terminate().
>
> But it still breaks cancellation. Again, ignoring cancel entirely may be
> "cancel safe" in some trivial sense, but it's not useful or reasonable
> under nearly all circumstances.
I'm not suggesting that catching a cancellation request and not
rethrowing it is a good thing. I'm trying to point out that - sometimes
- the C++ language rules leave with me no other choice. A second
exception escaping from a destructor called while unwinding the stack
because of some earlier exception will result in program termination.
If catching (and not rethrowing) this second exception breaks the
cancellation machinery, then it is the cancellation machinery - and not
the program in question - that is broken. In other words: we need a way
to prevent this scenario.
- Wil
More information about the c++-pthreads
mailing list