]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-126910: avoid reading the FP for getting the SP (GH-146521)
authorDiego Russo <diego.russo@arm.com>
Fri, 27 Mar 2026 17:52:48 +0000 (17:52 +0000)
committerGitHub <noreply@github.com>
Fri, 27 Mar 2026 17:52:48 +0000 (01:52 +0800)
Include/internal/pycore_pystate.h
Python/pystate.c

index 189a8dde9f09ed61f0d26a789be90578e73269c6..a66543cf1eb164c26f883c91734e63d296493c03 100644 (file)
@@ -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)
index 143175da0f45c775fbf7927ec34196a5d843f543..f974c82c391f6a5211c4ad81c9f8949c4842942d 100644 (file)
@@ -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
+}