https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71951
--- Comment #11 from Wilco <wdijkstr at arm dot com> --- (In reply to Icenowy Zheng from comment #10) > In my environment (glibc 2.25, and both the building scripts of glibc and > gcc have -fomit-frame-pointer automatically enabled), this bug is not fully > resolved yet. > > With GCC upgraded to 6.4.0, GDB debugger started to work correctly. (With > GCC 6.3.0 GDB cannot even work and segfault at unwind code in libgcc). > > However, if I still build GCC with -fomit-frame-pointer in CFLAGS, the > backtrace() function of glibc cannot work, and segfault at line 240 of > libgcc/unwind-dw2.c . > > By reading the source code, I think the unwind code is still trying to get > CFA from the register x29, and when debugging I found that the x29 register > in the unwind context is 0 (because of -fomit-frame-pointer), so line 240 is > dereferencing a NULL pointer, so it segfaulted. > > Maybe the behavior that accessing x29 register to get CFA is not correct? Well if everything built with -fomit-frame-pointer then it is definitely wrong to read x29. Can you give more info similar to comment #3?