Skip to content

Commit

Permalink
[libunwind] fix unwinding from signal handler
Browse files Browse the repository at this point in the history
In case of this is frame of signal handler, the IP should be
incremented, because the IP saved in the signal handler points to first
non-executed instruction, while FDE/CIE expects IP to be after the
first non-executed instruction.

Refs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26208
  • Loading branch information
azat committed May 15, 2024
1 parent 9bbefb7 commit 5e3635c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libunwind/src/DwarfInstructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,12 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc,

// Return address is address after call site instruction, so setting IP to
// that does simulates a return.
newRegisters.setIP(returnAddress);
//
// In case of this is frame of signal handler, the IP should be
// incremented, because the IP saved in the signal handler points to
// first non-executed instruction, while FDE/CIE expects IP to be after
// the first non-executed instruction.
newRegisters.setIP(returnAddress + cieInfo.isSignalFrame);

// Simulate the step by replacing the register set with the new ones.
registers = newRegisters;
Expand Down

0 comments on commit 5e3635c

Please sign in to comment.