This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/71951] libgcc_s built with -fomit-frame-pointer on aarch64 is broken
- From: "icenowy at aosc dot io" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 27 Jul 2017 22:05:33 +0000
- Subject: [Bug target/71951] libgcc_s built with -fomit-frame-pointer on aarch64 is broken
- Auto-submitted: auto-generated
- References: <bug-71951-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71951
--- Comment #12 from Icenowy Zheng <icenowy at aosc dot io> ---
(In reply to Wilco from comment #11)
> (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?
I didn't remember a lot as this issue is already fixed in our build system by
removing -fomit-frame-pointer.
But I remember part of the stacktrace:
_Unwind_GetGR(index=29) at libgcc/unwind-dw2.c:240 <= segfault here
_Unwind_GetPtr(index=29) at libgcc/unwind-dw2.c:251
uw_update_context_1() at libgcc/unwind-dw2.c:1410
_Unwind_Backtrace() at libgcc/unwind.inc (line number forgot)
backtrace() in libc.so.6