https://github.com/python/cpython/commit/acd5b9708222e768fe0d0e1fb6071c6602acb63f
commit: acd5b9708222e768fe0d0e1fb6071c6602acb63f
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2025-12-10T22:54:28Z
summary:

[3.14] gh-137007: Track executor before any possible deallocations (GH-137016) 
(GH-142541)

gh-137007: Track executor before any possible deallocations (GH-137016)
(cherry picked from commit 97e19014ddc652beae58e7eceb591f5d65a875e6)

Co-authored-by: Ken Jin <[email protected]>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2025-07-22-16-20-06.gh-issue-137007.1oPvvK.rst
M Python/optimizer.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2025-07-22-16-20-06.gh-issue-137007.1oPvvK.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-22-16-20-06.gh-issue-137007.1oPvvK.rst
new file mode 100644
index 00000000000000..cb25fd10c0bd2c
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-22-16-20-06.gh-issue-137007.1oPvvK.rst
@@ -0,0 +1 @@
+Fix a bug during JIT compilation failure which caused garbage collection debug 
assertions to fail.
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 6679eecd648a85..3a66aeb4f827b3 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -1213,6 +1213,10 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int 
length, const _PyBloomFil
     assert(next_exit == -1);
     assert(dest == executor->trace);
     assert(dest->opcode == _START_EXECUTOR);
+    // Note: we MUST track it here before any Py_DECREF(executor) or
+    // linking of executor. Otherwise, the GC tries to untrack a
+    // still untracked object during dealloc.
+    _PyObject_GC_TRACK(executor);
     _Py_ExecutorInit(executor, dependencies);
 #ifdef Py_DEBUG
     char *python_lltrace = Py_GETENV("PYTHON_LLTRACE");
@@ -1242,7 +1246,6 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int 
length, const _PyBloomFil
         return NULL;
     }
 #endif
-    _PyObject_GC_TRACK(executor);
     return executor;
 }
 

_______________________________________________
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