[libunwind] [libunwind] fix unwinding from signal handler (PR #92291)
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 7 12:55:23 PDT 2024
================
@@ -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);
----------------
compnerd wrote:
I guess I'm thinking about someone using libunwind and manually walking the FDE. The single step alters the register state (`.setIP`). As long as you are just walking the FDE for unwinding as we do it is fine, but were someone to do something non-standard in between, it would just give you an unaligned IP.
https://github.com/llvm/llvm-project/pull/92291
More information about the cfe-commits
mailing list