https://github.com/python/cpython/commit/6bbc28bc9c50ef81cb83d859f3b483e1b6928943
commit: 6bbc28bc9c50ef81cb83d859f3b483e1b6928943
branch: 3.15
author: Stan Ulbrych <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-07-01T19:20:27Z
summary:

[3.15] gh-151040: Fix `test_c_stack_unwind` on RISC-V (GH-152370) (#152819)

(cherry picked from commit 1b0c05f14807a43d070127b3d8eac1af8de27f28)

Co-authored-by: Ivy Xu <[email protected]>

files:
M Modules/_testinternalcapi.c

diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 92a49d003ca735..344d663624b270 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -98,6 +98,11 @@ static const uintptr_t min_frame_pointer_addr = 0x1000;
 // https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
 #  define FRAME_POINTER_NEXT_OFFSET 0
 #  define FRAME_POINTER_RETURN_OFFSET 2
+#elif defined(__riscv)
+// RISC-V saves the return address at fp[-1], and the previous frame pointer 
at fp[-2].
+// See: 
https://riscv-non-isa.github.io/riscv-elf-psabi-doc/#_frame_pointer_convention
+#  define FRAME_POINTER_NEXT_OFFSET -2
+#  define FRAME_POINTER_RETURN_OFFSET -1
 #else
 #  define FRAME_POINTER_NEXT_OFFSET 0
 #  define FRAME_POINTER_RETURN_OFFSET 1

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to