http://sourceware.org/bugzilla/show_bug.cgi?id=14271
Bug #: 14271 Summary: exception handling broken in combination with gcc static libs Product: binutils Version: 2.22 Status: NEW Severity: normal Priority: P2 Component: gold AssignedTo: i...@airs.com ReportedBy: christopher.h...@partner.commerzbank.com CC: ccout...@google.com Classification: Unclassified repost of this: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53730 ============ This code should terminate cleanly. int main(){ try{ throw 4; }catch(...) {} return 0; } Program received signal SIGABRT, Aborted. 0x00c4b410 in __kernel_vsyscall () (gdb) where #0 0x00c4b410 in __kernel_vsyscall () #1 0x005fcd10 in raise () from /lib/libc.so.6 #2 0x005fe621 in abort () from /lib/libc.so.6 #3 0x0805769d in uw_init_context_1 (context=0xbfffbc00, outer_cfa=0xbfffbde0, outer_ra=0x804cef1) at ../../../gcc-4.7.0/libgcc/unwind-dw2.c:1501 #4 0x00000000 in ?? () It seems to fail an assertion here in unwind-dw2.c: gcc_assert (code == _URC_NO_REASON); Some combination of LTO and statically linking standard libs breaks exceptions and breaks backtrace. * removing -flto -fuse-linker-plugin fixes it * removing both -static-libgcc -static-libstdc++ fixes it * removing just -static-libgcc results in the catch not working fine g++ -pthread -m32 -O3 -g -march=core2 -rdynamic -static-libgcc -static-libstdc++ throw_test.cpp aborts with broken stack - what I've got in production g++ -pthread -m32 -O3 -flto -fuse-linker-plugin -g -march=core2 -rdynamic -static-libgcc -static-libstdc++ throw_test.cpp terminate called after throwing an instance of 'int' terminate called recursively Aborted (core dumped) g++ -pthread -m32 -O3 -flto -fuse-linker-plugin -g -march=core2 -rdynamic -static-libstdc++ throw_test.cpp fine g++ -pthread -m32 -O3 -flto -fuse-linker-plugin -g -march=core2 -rdynamic -static-libgcc throw_test.cpp I'm using an ancient box with my own gcc and binutils: g++ (GCC) 4.7.0 binutils-2.22 Linux xmercd32 2.6.18-92.1.18.el5PAE #1 SMP Wed Nov 5 09:14:56 EST 2008 i686 i686 i386 GNU/Linux ../gcc-4.7.0/configure --with-gmp=$INSTALLATION/gmp-4.3.2 --with-mpfr=$INSTALLATION/mpfr-2.4.2 --with-mpc=$INSTALLATION/mpc-0.8.2 --with-ppl=$INSTALLATION/ppl-0.11 --enable-cloog-backend=isl --with-cloog=$INSTALLATION/cloog-0.16.2 --prefix=$INSTALLATION/gcc-4.7.0 -enable-languages=c,c++ \ --enable-lto --with-libelf=$INSTALLATION/libelf-0.8.12 --enable-gold --with-ld=$INSTALLATION/binutils-2.22/bin/ld --with-as=$INSTALLATION/binutils-2.22/bin/as ./configure --enable-gold --enable-plugins --enable-lto --with-gmp=$INSTALLATION/gmp-4.3.2 --with-mpfr=$INSTALLATION/mpfr-2.4.2 --with-mpc=$INSTALLATION/mpc-0.8.2 --with-ppl=$INSTALLATION/ppl-0.11 --enable-cloog-backend=isl --with-cloog=$INSTALLATION/cloog-0.16.2 --prefix=$INSTALLATION/binutils-2.22 \ --disable-werror /fs/tools/L4/binutils-2.22/bin/ld -> /fs/tools/L4/binutils-2.22/bin/ld.gold ------ additionally I was able to reproduce this on a 64-bit box Linux linuxap03 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux The the cases above produced the same results for -m64. ------ the behavior changes when putting LTO info into static libs export CFLAGS=-flto export CXXFLAGS=-flto and then rebuilding gcc changes the behavior, but doesn't fix it g++ -pthread -m64 -O3 -flto -fuse-linker-plugin -g -march=core2 -rdynamic -static-libgcc -static-libstdc++ throw_test.cpp $./a.out terminate called after throwing an instance of 'int' terminate called recursively Aborted (core dumped) Perhaps and LTO build should build all static libs with LTO. On my 64-bit box I get different behavior for 64- and 32-bit. g++ -m64 -O3 throw_test.cpp Aborted (core dumped) g++ -m32 -O3 throw_test.cpp <fine> -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils