[c++-pthreads] Re: pthread_cancel and EH: let's try this again
George Shimanovich
gshiman at commvault.com
Wed Jul 13 17:24:21 UTC 2005
Below is my old note to Jakub with description of failure in my Linux
pthread test program which is based on thread pool implementation, i.e.
it has to catch exceptions thrown by cancelled worker thread. That
illustrates why we could not use Linux pthread. From my point of view
this is caused by use of EH to implement thread cancellation.
- George
-----Original Message-----
From: George Shimanovich
Sent: Thursday, June 24, 2004 3:52 PM
To: 'Jakub Jelinek'
Subject: RE: Bug 111548: calling pthread_cancel in a muti-thread c++
application abort()s the app - 'cancel state' workaround
Jakub,
I just implemented workaround that you suggested - for deferred threads,
- with the same result:
1) disable cancel state at the beginning of new thread
2) enable it before each call to pthread_testcancel()
3) disable cancel state after each call to pthread_testcancel() Just to
make sure I explicitly set pending cancel type. The result is the same:
program crashed with 'FATAL: exception not rethrown' even though I
faithfully rethrow exception. It is worth noting that cancel point did
not seem to work and thread was wacked before call to
pthread_testcancel().
The main problem as I see it is this:
Linux pthreads crashes the process when unwinding stack of cancelled
thread: it throws system (non C++ exception) which crashes the program
in both cases:
- when caught and rethrown
- when not caught
C++-pthreads spend a lot of time on discussing whether to issue or not
to issue an exception when thread is cancelled but does not mention
the fact that program crashes in the way outlined above. It is not an
issue of what is better: to throw or not to throw. It is simply that
pthreads in current state is unusable for multi-threading.
George Shimanovich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/c++-pthreads/attachments/20050713/25e410b7/attachment.html>
More information about the c++-pthreads
mailing list