[c++-pthreads] Re: Re: pthread_cancel and EH: let's try this again
Mark Mitchell
mark at codesourcery.com
Fri Jul 15 18:07:31 UTC 2005
Peter Dimov wrote:
>>WRT scheme #1, various people have wondered why re-asserting
>>cancellation in the exception's destructor is necessary.
I think that this is a tangent we should avoid for the moment. The
variant of #1 in which the cancellation exception is handled, ending
cancellation, and the variant of #1 in which cancellation is re-asserted
when the cancellation exception is handled are very similar. So, if we
got consensus that we wanted one of these two variants, that would be a
major step forward. From my point of view, either of these is OK.
The key idea behind this whole discussion is that we're trying to make
existing code work; if there were no existing code, it seems that
everyone would agree that one of the variants of #1 is best.
But, what we don't agree about is what we mean by "existing code".
Jason means code that was written to use pthread_cleanup_{push,pop} on
GNU/Linux before it was a proper exception, and which therefore does not
expect unwinding to occur. However, the customer code in question is
apparently able to tolerate destructors being run, even while skipping
over catch clauses. I certainly believe that this is true of some code,
but that's completely untrue in the general case.
Another kind of existing code is cross-platform, exception-safe
libraries. These, if written well, can handle arbitrary exceptions
passing through them, but do not, in general, handle things that behave
like exceptions, expect that catch clauses are not run. The
counter-argument here is that such libraries may require changes to
handle thread cancellation anyhow, if they call POSIX cancellation
points without expecting them to throw exceptions. That's true -- but
many of them don't. They do, however, call user functions which may
take arbitrary action, including throwing exceptions.
I'm not sure how compelling either existing code argument is, but I
don't see that the first argument is anywhere near strong enough to
cause us to develop an informal standard around the model that everyone
seems to agree is inferior in the abstract.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
(916) 791-8304
More information about the c++-pthreads
mailing list