Skip to content

Commit acd5b97

Browse files
[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 97e1901) Co-authored-by: Ken Jin <[email protected]>
1 parent cbec73c commit acd5b97

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug during JIT compilation failure which caused garbage collection debug assertions to fail.

Python/optimizer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,10 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
12131213
assert(next_exit == -1);
12141214
assert(dest == executor->trace);
12151215
assert(dest->opcode == _START_EXECUTOR);
1216+
// Note: we MUST track it here before any Py_DECREF(executor) or
1217+
// linking of executor. Otherwise, the GC tries to untrack a
1218+
// still untracked object during dealloc.
1219+
_PyObject_GC_TRACK(executor);
12161220
_Py_ExecutorInit(executor, dependencies);
12171221
#ifdef Py_DEBUG
12181222
char *python_lltrace = Py_GETENV("PYTHON_LLTRACE");
@@ -1242,7 +1246,6 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
12421246
return NULL;
12431247
}
12441248
#endif
1245-
_PyObject_GC_TRACK(executor);
12461249
return executor;
12471250
}
12481251

0 commit comments

Comments
 (0)