From c4b5a7821dbcca2a7d81daa90947bf7d5d1abdf0 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Mon, 8 Dec 2025 15:43:27 -0500 Subject: [PATCH] [3.14] gh-133932: Tagged ints are heap-safe (free threading) The previous fix (gh-134494) didn't fix the free threading build. --- Include/internal/pycore_stackref.h | 2 +- .../2025-12-08-15-46-06.gh-issue-133932.HAxa4p.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-12-08-15-46-06.gh-issue-133932.HAxa4p.rst diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 0ce759fc743d82..52acd918c9b9f9 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -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 index 00000000000000..460226303599e2 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-08-15-46-06.gh-issue-133932.HAxa4p.rst @@ -0,0 +1,2 @@ +Fix crash in the free threading build when clearing frames that hold tagged +integers.