https://github.com/python/cpython/commit/b60b9261b5de1e77755cbbeaa7c431e6c475de6e
commit: b60b9261b5de1e77755cbbeaa7c431e6c475de6e
branch: main
author: Diego Russo <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2026-03-28T01:52:48+08:00
summary:
GH-126910: avoid reading the FP for getting the SP (GH-146521)
files:
M Include/internal/pycore_pystate.h
M Python/pystate.c
diff --git a/Include/internal/pycore_pystate.h
b/Include/internal/pycore_pystate.h
index 189a8dde9f09ed..a66543cf1eb164 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -312,18 +312,7 @@ static uintptr_t return_pointer_as_int(char* p) {
}
#endif
-static inline uintptr_t
-_Py_get_machine_stack_pointer(void) {
-#if _Py__has_builtin(__builtin_frame_address) || defined(__GNUC__)
- return (uintptr_t)__builtin_frame_address(0);
-#elif defined(_MSC_VER)
- return (uintptr_t)_AddressOfReturnAddress();
-#else
- char here;
- /* Avoid compiler warning about returning stack address */
- return return_pointer_as_int(&here);
-#endif
-}
+PyAPI_DATA(uintptr_t) _Py_get_machine_stack_pointer(void);
static inline intptr_t
_Py_RecursionLimit_GetMargin(PyThreadState *tstate)
diff --git a/Python/pystate.c b/Python/pystate.c
index 143175da0f45c7..f974c82c391f6a 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -3286,3 +3286,16 @@ _Py_GetMainConfig(void)
}
return _PyInterpreterState_GetConfig(interp);
}
+
+uintptr_t
+_Py_get_machine_stack_pointer(void) {
+#if _Py__has_builtin(__builtin_frame_address) || defined(__GNUC__)
+ return (uintptr_t)__builtin_frame_address(0);
+#elif defined(_MSC_VER)
+ return (uintptr_t)_AddressOfReturnAddress();
+#else
+ char here;
+ /* Avoid compiler warning about returning stack address */
+ return return_pointer_as_int(&here);
+#endif
+}
_______________________________________________
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]