On 08/25/2011 02:26 PM, Andrew Haley wrote:
Throwing an exception through a segfault handler doesn't always work
on ARM: the attached example fails on current gcc trunk.
panda-9:~ $ g++ segv.cc -fnon-call-exceptions -g
panda-9:~ $ ./a.out
terminate called after throwing an instance of 'FoobarException*'
Aborted
The bug is that _Unwind_GetIPInfo doesn't correctly set ip_before_insn.
Instead, it always sets it to zero; it should be set to 1 if this
is a frame created by a signal handler:
#define _Unwind_GetIPInfo(context, ip_before_insn) \
(*ip_before_insn = 0, _Unwind_GetGR (context, 15)& ~(_Unwind_Word)1)
Fixing this on ARM is hard because signal frames aren't specially
marked as they are on systems that use DWARF unwinder data. I have
a patch that works on systems where the signal restorer is exactly
mov r7, $SYS_rt_sigreturn
swi 0x0
It works as a proof of concept, but it's fugly.
So, suggestions welcome. Is there a nice way to detect a signal frame?
Libunwind also reads the IP to detect signal frames on ARM Linux:
http://git.savannah.gnu.org/gitweb/?p=libunwind.git;a=blob;f=src/arm/Gis_signal_frame.c;hb=HEAD
I'd also be interested if there are better approaches to detect them. :)
Regards
Ken