gh-142476: fix memory leak when creating JIT executors (GH-142492)

This commit is contained in:
Shamil 2025-12-19 22:07:11 +03:00 committed by GitHub
parent 6b4bc6e6a2
commit e2a7db7175
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -185,12 +185,17 @@ _PyOptimizer_Optimize(
else {
executor->vm_data.code = NULL;
}
executor->vm_data.chain_depth = chain_depth;
assert(executor->vm_data.valid);
_PyExitData *exit = _tstate->jit_tracer_state.initial_state.exit;
if (exit != NULL) {
exit->executor = executor;
}
executor->vm_data.chain_depth = chain_depth;
assert(executor->vm_data.valid);
else {
// An executor inserted into the code object now has a strong reference
// to it from the code object. Thus, we don't need this reference anymore.
Py_DECREF(executor);
}
interp->compiling = false;
return 1;
#else