Ian Lance Taylor <iant@xxxxxxxxxx> writes: > Anybody out there want to try to recreate this? % cat cancel.cc #include <cxxabi.h> #include <error.h> #include <pthread.h> #include <stdexcept> #include <stdio.h> #include <stdlib.h> #include <unistd.h> void cancel_and_rethrow () { try { pthread_cancel (pthread_self ()); pthread_testcancel (); } catch (abi::__forced_unwind &) { throw; } catch (...) { throw; } } void * start_routine_bad (void *) { try { throw std::runtime_error ("let's get to an exception handler"); } catch (const std::exception &) { cancel_and_rethrow (); } return NULL; } void * start_routine_good (void *) { cancel_and_rethrow (); return NULL; } int main (int argc, char **argv) { pthread_t thread; int errnum; void *result; errnum = pthread_create (&thread, NULL, argc > 1 ? start_routine_good : start_routine_bad, NULL); if (errnum != 0) error (EXIT_FAILURE, errnum, "Cannot create thread"); errnum = pthread_join (thread, &result); if (errnum != 0) error (EXIT_FAILURE, errnum, "Cannot join thread"); if (result == PTHREAD_CANCELED) puts ("Thread was canceled"); return 0; } % g++-4.7 -v -pthread -g -fasynchronous-unwind-tables cancel.cc -o cancel Using built-in specs. COLLECT_GCC=g++-4.7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.0-3' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.0 (Debian 4.7.0-3) COLLECT_GCC_OPTIONS='-v' '-pthread' '-g' '-fasynchronous-unwind-tables' '-o' 'cancel' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D_REENTRANT cancel.cc -quiet -dumpbase cancel.cc -mtune=generic -march=x86-64 -auxbase cancel -g -version -fasynchronous-unwind-tables -o /tmp/ccyUtyuF.s GNU C++ (Debian 4.7.0-3) version 4.7.0 (x86_64-linux-gnu) compiled by GNU C version 4.7.0, GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.7 /usr/include/c++/4.7/x86_64-linux-gnu /usr/include/c++/4.7/backward /usr/lib/gcc/x86_64-linux-gnu/4.7/include /usr/local/include v /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU C++ (Debian 4.7.0-3) version 4.7.0 (x86_64-linux-gnu) compiled by GNU C version 4.7.0, GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 88533e713bc5fbae1d71c18870b89018 COLLECT_GCC_OPTIONS='-v' '-pthread' '-g' '-fasynchronous-unwind-tables' '-o' 'cancel' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as --64 -o /tmp/ccg5xS6h.o /tmp/ccyUtyuF.s COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/ LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-pthread' '-g' '-fasynchronous-unwind-tables' '-o' 'cancel' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.7/collect2 --sysroot=/ --build-id --no-add-needed --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cancel /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.7 -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. /tmp/ccg5xS6h.o -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o % ./cancel terminate called after throwing an instance of 'std::runtime_error' what(): let's get to an exception handler zsh: abort (core dumped) ./cancel % ./cancel good Thread was canceled % dpkg -l libc6 libgcc1 Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-===========================-===========================-====================================================================== ii libc6:amd64 2.13-30 Embedded GNU C Library: Shared libraries ii libgcc1:amd64 1:4.7.0-3 GCC support library %