GCC 4.6.2 C++ thread cancellation issue

Mike Dalpee mikedalpee@enginsol.com
Fri May 11 20:24:00 GMT 2012


Oops, missed your first comment - attached are both corrected files.

________________________________________
From: Jonathan Wakely [jwakely.gcc@gmail.com]
Sent: Friday, May 11, 2012 3:13 PM
To: Mike Dalpee
Cc: Ian Lance Taylor; gcc-help@gcc.gnu.org
Subject: Re: GCC 4.6.2 C++ thread cancellation issue

On 11 May 2012 19:41, Mike Dalpee wrote:
> Ok, I have provided the two examples as attachments.  I had to transcribe these from printouts, so I apologize if there are any typos that prevent them from immediately compiling.

Both files need
s/pthread tid;/pthread_t tid;/

For the first program I get no abort:

Thread created
In ThreadRun
In Some3rdPartyFunction
Cancelling Thread
Joining cancelled thread
Rethrowing abi::_forced_unwind
Returning from main

Did you mean to put an empty exception specification on the
Some3rdPartyFunction?

For the second I see an abort

Thread created
In ThreadRun
Handling int exception
In Some3rdPartyFunction
Cancelling Thread
Joining cancelled thread
terminate called after throwing an instance of 'int'
Aborted

> I used the following commands to build these:
>
> gcc -g bug1.cpp -o bug1 -lstdc++ -lpthread
> gcc -g bug2.cpp -o bug2 -lstdc++ -lpthread

It won't change the behaviour, but any reason you don't use these
commands instead?

g++ -g bug1.cpp -o bug1 -pthread
g++ -g bug2.cpp -o bug2 -pthread

i.e. compile with the g++ driver so libstdc++ is linked in
automatically, and use -pthread so _REENTRANT is defined, as well as
linking to libpthread.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug1.cpp
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20120511/95e94db9/attachment-0002.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug2.cpp
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20120511/95e94db9/attachment-0003.ksh>


More information about the Gcc-help mailing list