This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/85492] riscv64: endless loop when throwing an exception from a constructor
- From: "wilson at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 27 Apr 2018 19:59:22 +0000
- Subject: [Bug target/85492] riscv64: endless loop when throwing an exception from a constructor
- Auto-submitted: auto-generated
- References: <bug-85492-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85492
--- Comment #3 from Jim Wilson <wilson at gcc dot gnu.org> ---
I figured out that I wasn't fully rebuilding and relinking all libraries while
trying to debug this with printf, and that sent me down the wrong path.
Trying this again, correctly, I see that we have a loop in unwind, because the
return address for _start is pointing at _start. This works by accident when
static linking, because crt1.o is included before crtbegin.o, crtbegin.o
registers FDEs starting from a label it adds to the eh_frame section, and hence
the FDE for _start in crt1.o gets lost. When unwinding, we see that there is
no FDE for _start, and it isn't an exception frame, so that terminates
unwinding. When dynamic linking, we use PT_GNU_EH_FRAME which uses eh_frame
section addresses and hence finds every FDE, including the one for _start, so
we try to unwind through _start, get a return address pointing at _start, and
go into an infinite loop.
This requires a glibc patch to fix. Just setting the return address in _start
to 0 works.