Skip to content

Commit 97e1901

Browse files
gh-137007: Track executor before any possible deallocations (GH-137016)
1 parent 26757d1 commit 97e1901

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
@@ -1310,6 +1310,10 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
13101310
assert(next_exit == -1);
13111311
assert(dest == executor->trace);
13121312
assert(dest->opcode == _START_EXECUTOR);
1313+
// Note: we MUST track it here before any Py_DECREF(executor) or
1314+
// linking of executor. Otherwise, the GC tries to untrack a
1315+
// still untracked object during dealloc.
1316+
_PyObject_GC_TRACK(executor);
13131317
_Py_ExecutorInit(executor, dependencies);
13141318
#ifdef Py_DEBUG
13151319
char *python_lltrace = Py_GETENV("PYTHON_LLTRACE");
@@ -1338,7 +1342,6 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
13381342
return NULL;
13391343
}
13401344
#endif
1341-
_PyObject_GC_TRACK(executor);
13421345
return executor;
13431346
}
13441347

0 commit comments

Comments
 (0)