[c++-pthreads] Re: pthread_cancel and EH: let's try this again
Mark Mitchell
mark at codesourcery.com
Fri Jul 15 22:57:46 UTC 2005
Wil Evers wrote:
> I agree, but please note that the handling of catch (...) blocks is not
> the only distinction between model #1 and model #2.
>
> In model #2, cancellation is disabled in all destructors; in model #1,
> cancellation is only disabled when destructors are called while
> unwinding the stack.
>
> In other words, #2 has the desirable property that it does not break
> existing code that assumes destructors *never* throw. I suspect that a
> lot of code relies on that assumption, and I know for sure that
> practically all of my code does.
Good point.
However, that seems orthogonal to the other issues; we could certainly
have #1 disallow cancellation in all destructors, if we wanted. I don't
really know how we plan to do that in #2, without inserting additional
code in every destructor, which seems unfortunate.
> Supposing model #1 is accepted, then how do we cope with existing code
> that assumes destructors never throw, or, more generally, with code that
> was not written to deal with exceptions thrown from cancellation points?
The compiler must know that cancellation points may throw exceptions, as
otherwise it may have optimized away exception unwind information, as it
would when calling any "nothrow" function.
However, I realize that you're asking about user code, more than about
the compiler.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
(916) 791-8304
More information about the c++-pthreads
mailing list