]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-133932: Tagged ints are heap-safe (free threading) (gh-142431)
authorSam Gross <colesbury@gmail.com>
Mon, 8 Dec 2025 23:16:28 +0000 (18:16 -0500)
committerGitHub <noreply@github.com>
Mon, 8 Dec 2025 23:16:28 +0000 (18:16 -0500)
The previous fix (gh-134494) didn't fix the free threading build.

Include/internal/pycore_stackref.h
Misc/NEWS.d/next/Core_and_Builtins/2025-12-08-15-46-06.gh-issue-133932.HAxa4p.rst [new file with mode: 0644]

index 0ce759fc743d823b5175c06eb6ff030f54ae22cb..52acd918c9b9f9b7640367e702c1fd8b148be2b8 100644 (file)
@@ -323,7 +323,7 @@ _PyStackRef_FromPyObjectSteal(PyObject *obj)
 static inline bool
 PyStackRef_IsHeapSafe(_PyStackRef stackref)
 {
-    if (PyStackRef_IsDeferred(stackref)) {
+    if (PyStackRef_IsDeferred(stackref) && !PyStackRef_IsTaggedInt(stackref)) {
         PyObject *obj = PyStackRef_AsPyObjectBorrow(stackref);
         return obj == NULL || _Py_IsImmortal(obj) || _PyObject_HasDeferredRefcount(obj);
     }
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-08-15-46-06.gh-issue-133932.HAxa4p.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-08-15-46-06.gh-issue-133932.HAxa4p.rst
new file mode 100644 (file)
index 0000000..4602263
--- /dev/null
@@ -0,0 +1,2 @@
+Fix crash in the free threading build when clearing frames that hold tagged
+integers.