https://github.com/azat created https://github.com/llvm/llvm-project/pull/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

>From 5e3635c1852ac280f06f9e54793d4181d2845b64 Mon Sep 17 00:00:00 2001
From: Azat Khuzhin <a3at.m...@gmail.com>
Date: Wed, 15 May 2024 08:17:22 +0200
Subject: [PATCH] [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.

Refs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26208
---
 libunwind/src/DwarfInstructions.hpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libunwind/src/DwarfInstructions.hpp 
b/libunwind/src/DwarfInstructions.hpp
index bd9ece60ee588..5ea535be4b974 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -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;

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to