The attached testcase usually segfaults on i?86-linux and x86_64-linux (and likely on most other DWARF2_UNWIND_INFO 1 targets, though the testcase would need to be tweaked for them). The problem is that instruction pointer saved in the signal frame is after last successfully executed instruction and before first non-executed instruction, while .eh_frame and unwind-dw2.c basically expects context->ra to be after the first non-executed instruction. To find FDE, unwind-dw2.c uses context->ra - 1, which is good for normal unwinding, but if e.g. a signal is sent while $pc is at the very beginning of some function, context->ra - 1 either corresponds to a previous function or is not covered by any FDE. Similarly, execute_cfa_program has a loop: while (insn_ptr < insn_end && fs->pc < context->ra) which is good in most cases, but when context->ra is saved IP from sigcontext in signal frame, this means that the last set of unwind instructions will not be executed, while it ought to (for signal frame context->ra we'd need to also execute fs->pc == context->ra instructions).
-- Summary: Serious problem with unwinding through signal frames Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26208