pthread_cancel and EH: let's try this again

Alexander Terekhov terekhov at web.de
Sat Jul 23 13:53:56 UTC 2005


Peter Dimov wrote:
> 
> Alexander Terekhov wrote:
> > Peter Dimov wrote:
> > [...]
> >> D. to match POSIX semantics, cancellation points don't throw if
> >> there is an unfinished exception.
> >
> > It actually breaks straight POSIX semantics.
> >
> >  int main() {
> >    pthread_cancel(pthread_self());
> >    try { throw 0; } catch(...) { pthread_testcancel(); }
> >    printf("Never reach this point under straight POSIX.");
> >  }
> 
> Yes, it does change the behavior of such programs. I'm hoping that it
> doesn't break them, though, because it only delays the cancellation
> exception a while, and there is usually a race between the pthread_cancel
> and the pthread_testcancel in real code.

Race or no race, there's nothing particularly unusual to have 
things like pthread_cond_wait() in the dynamic or static context 
of conventional catch. Your change may result in threads blocked 
forever. 

> 
> > This probably won't please Tru64 and OpenVMS folk.
> 
> The only way to find out is to implement these semantics and see what
> happens.

I'd rather save the embarrassment. ;-)

regards,
alexander.




More information about the c++-pthreads mailing list