LTO breaks exceptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Chris



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux