On 08/25/2011 05:26 AM, 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.

For what it's worth, I did the equivalent on MIPS.

Once you do this, it is a de facto ABI. Probably the ARM linux maintainers should be consulted to see if they are willing to consider the possibility of never changing it.

I think all Linux ABIs should support unwinding through signal handlers, so adding this makes sense to me.

David Daney


So, suggestions welcome.  Is there a nice way to detect a signal frame?

Reply via email to