From 7b604cdf75fd1c741a15138684ea0e98dca5e46f Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 9 Jul 2024 22:57:00 +0300 Subject: [PATCH] [libunwind] fix unwinding from signal handler (#92291) 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 --- libunwind/src/UnwindCursor.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 677e842d8a22..2ec60e4c123d 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -2589,6 +2589,14 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { --pc; #endif +#if !(defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)) + // In case of this is frame of signal handler, 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. + if (_isSignalFrame) + ++pc; +#endif + // Ask address space object to find unwind sections for this pc. UnwindInfoSections sects; if (_addressSpace.findUnwindSections(pc, sects)) {