This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
re: C++ vs. pthread_cancel
- From: Peter Zijlstra <a dot p dot zijlstra at chello dot nl>
- To: Dan Kegel <dank at kegel dot com>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Mon, 15 Aug 2005 15:36:08 +0200
- Subject: re: C++ vs. pthread_cancel
- References: <430094CA.3020001@kegel.com>
On Mon, 2005-08-15 at 06:12 -0700, Dan Kegel wrote:
> Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > On this controversial subject, could somebody please - pretty please
> > with a cherry on top - tell me what the current status is:
> > - in general,
> > - as implemented in the 3.4 series and
> > - as implemented in the 4.0 series.
> >
> > At work we're using 3.4 and we have managed to shoot our foot of with
> > this issue :-(, google gives a lot of hits on the issue but it is a bit
> > hard to get the current impl. status for 3.4. Which in turn makes it
> > hard to decide on how to bandage our foot.
>
> Could you provide a link to a description of the particular
> problem? I looked around, and all I could find was
> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=111548
>
> I suppose the controversial part is that you're using
> pthread_cancel, which is somewhat frowned upon as
> inherently unsafe.
> - Dan
>
Yes, is seems to be that problem.
Discussion here:
http://gcc.gnu.org/ml/gcc/2003-12/msg00743.html
And this list seems dedicated to the problem:
http://www.codesourcery.com/archives/c++-pthreads/maillist.html
The issue seems to be that pthread_cancel is implemented using
force_unwind, the same mechanism as used for exception handling. And the
interaction is ill defined.
The behaviour of gcc-3.4 is that the unclassified exception caused by
SIGCANCEL can be caught by the catch-all clause: 'catch (...)'. And then
when not rethrown causes an abort.
Peter Zijlstra