http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60758
Bug ID: 60758 Summary: Infinite backtrace in __cxa_end_cleanup Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: alexey.merzlyakov at samsung dot com CC: v.garbuzov at samsung dot com, y.gribov at samsung dot com Target: arm Created attachment 32542 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32542&action=edit Testcase to reproduce While debugging a compiled testcase, the infinite backtrace appears: Breakpoint 1, __gnu_end_cleanup () at ../../../../gcc-src/libstdc++-v3/libsupc++/eh_arm.cc:134 134 ../../../../gcc-src/libstdc++-v3/libsupc++/eh_arm.cc: No such file or directory. (gdb) bt #0 __gnu_end_cleanup () at ../../../../gcc-src/libstdc++-v3/libsupc++/eh_arm.cc:134 #1 0xb6f45b2c in __cxa_end_cleanup () from /lib/libstdc++.so.6 #2 0xb6f45b2c in __cxa_end_cleanup () from /lib/libstdc++.so.6 #3 0xb6f45b2c in __cxa_end_cleanup () from /lib/libstdc++.so.6 #4 0xb6f45b2c in __cxa_end_cleanup () from /lib/libstdc++.so.6 ... GCC configuration: $ arm-linux-gnueabi-gcc -v Using built-in specs. COLLECT_GCC=./arm-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=/home/alexey.merzlyakov/arm/libexec/gcc/arm-linux-gnueabi/4.9.0/lto-wrapper Target: arm-linux-gnueabi Configured with: ../gcc-src/configure --host=i686-pc-linux-gnu --target=arm-linux-gnueabi --prefix=/home/alexey.merzlyakov/arm --with-sysroot=/home/alexey.merzlyakov/arm/arm-linux-gnueabi/sys-root --disable-libmudflap --disable-libssp --with-mode=arm --with-fpu=vfpv3 --with-cpu=cortex-a15 --with-tune=cortex-a15 --with-float=softfp --disable-libatomic --disable-libgomp --enable-languages=c,c++ --with-gmp=/home/alexey.merzlyakov/arm --with-mpfr=/home/alexey.merzlyakov/arm --with-mpc=/home/alexey.merzlyakov/arm Thread model: posix gcc version 4.9.0 20140403 (experimental) (GCC) Compiling the testcase: $ arm-linux-gnueabi-g++ rethrow_if_nested.ii -std=gnu++0x -g The __cxa_end_cleanup() does not save/restore LR in function header/footer and does not provide any unwind info: libstdc++-v3/libsupc++/eh_arm.cc -> "__cxa_end_cleanup:\n" " push\t{r1, r2, r3, r4}\n" " bl\t__gnu_end_cleanup\n" " pop\t{r1, r2, r3, r4}\n" " bl\t_Unwind_Resume @ Never returns\n" GDB uses LR saving/restoring information when making a backtrace (when unwind info is not available). Otherwise if there are no information, the LR on current frame will be equal to LR on previous frame. It causes GDB to generate same backtrace-items for __cxa_end_cleanup again and again. I would expect the same problem for other tools that unwind stacks (e.g. unwind code in libgcc, libbacktrace, etc.). So, it seems to be a libstdc++ bug. Adding the LR in the arguments of save/restore instructions in __cxa_end_cleanup() code fixes it. Another option would be to add unwind entries (.cfi_whatever).