Skip to content

Commit 7066c0d

Browse files
committed
[libunwind] fix unwinding from signal handler
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. v2: move the increment from DwarfInstructions<A, R>::stepWithDwarf() into the UnwindCursor<A, R>::setInfoBasedOnIPRegister() to avoid exposing posslibly unaligned IP (also note, that this matches with gcc implementation as well) Refs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26208
1 parent 687531f commit 7066c0d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,12 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
25892589
--pc;
25902590
#endif
25912591

2592+
// In case of this is frame of signal handler, the IP saved in the signal
2593+
// handler points to first non-executed instruction, while FDE/CIE expects IP
2594+
// to be after the first non-executed instruction.
2595+
if (_isSignalFrame)
2596+
++pc;
2597+
25922598
// Ask address space object to find unwind sections for this pc.
25932599
UnwindInfoSections sects;
25942600
if (_addressSpace.findUnwindSections(pc, sects)) {

0 commit comments

Comments
 (0)