-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142476: fix memory leak when creating JIT executors #142492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ad78398
ae51767
2f9ab2c
dc5e8d3
cf6deac
bb950c2
29b4663
4068cf8
80af6fc
a22b512
94312c3
a166b47
1136bd2
f3a763a
26c577d
a483193
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix a memory leak in the experimental Tier 2 optimizer when creating | ||
| executors. Patched by Shamil Abdulaev. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,12 +185,16 @@ _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; | ||
| } 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); | ||
ashm-dev marked this conversation as resolved.
Show resolved
Hide resolved
sergey-miryanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| executor->vm_data.chain_depth = chain_depth; | ||
| assert(executor->vm_data.valid); | ||
| interp->compiling = false; | ||
| return 1; | ||
| #else | ||
|
|
@@ -310,7 +314,13 @@ add_to_pending_deletion_list(_PyExecutorObject *self) | |
| static void | ||
| uop_dealloc(PyObject *op) { | ||
| _PyExecutorObject *self = _PyExecutorObject_CAST(op); | ||
| _PyObject_GC_UNTRACK(self); | ||
|
|
||
| // Object might be already untracked if we are in a GC cycle (via tp_clear). | ||
| // Avoid double-untracking. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can add a TODO for now so we don’t lose track of this, but I don’t have the bandwidth at the moment to dig into the root cause and fix it properly. |
||
| if (_PyObject_GC_IS_TRACKED(self)) { | ||
| _PyObject_GC_UNTRACK(self); | ||
| } | ||
|
|
||
| assert(self->vm_data.code == NULL); | ||
| unlink_executor(self); | ||
| // Once unlinked it becomes impossible to invalidate an executor, so do it here. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.