]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-137007: Track executor before any possible deallocations (GH-137016)
authorKen Jin <kenjin@python.org>
Wed, 10 Dec 2025 21:09:56 +0000 (05:09 +0800)
committerGitHub <noreply@github.com>
Wed, 10 Dec 2025 21:09:56 +0000 (05:09 +0800)
Misc/NEWS.d/next/Core_and_Builtins/2025-07-22-16-20-06.gh-issue-137007.1oPvvK.rst [new file with mode: 0644]
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 (file)
index 0000000..cb25fd1
--- /dev/null
@@ -0,0 +1 @@
+Fix a bug during JIT compilation failure which caused garbage collection debug assertions to fail.
index 7fe914a7a426b9d40ba3196f72233e78db133ddc..b693581d7318bf016481c74dfacee5b7a0e80fc1 100644 (file)
@@ -1310,6 +1310,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");
@@ -1338,7 +1342,6 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
         return NULL;
     }
 #endif
-    _PyObject_GC_TRACK(executor);
     return executor;
 }