| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Fix memory leak in JIT executor on compilation failure | ||
|
|
||
| The executor object passed to the TIER1_TO_TIER2 macro was not | ||
| decremented if the Tier 2 code returned with an exception set but | ||
| without a fatal error (i.e., not returning NULL). | ||
|
|
||
| This change moves the Py_DECREF call inside the TIER1_TO_TIER2 | ||
| macro to ensure the executor's reference count is always decremented | ||
| after its execution, regardless of the outcome. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -351,12 +351,12 @@ _PyFrame_SetStackPointer(frame, stack_pointer) | |
|
|
||
| /* Tier-switching macros. */ | ||
|
|
||
| #define TIER1_TO_TIER2(EXECUTOR) \ | ||
| #define TIER1_TO_TIER2(EXECUTOR) \ | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy was this changed? please revert.
Sorry, something went wrong.
All reactions
|
||
| do { \ | ||
| OPT_STAT_INC(traces_executed); \ | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy was this changed? please revert.
Sorry, something went wrong.
All reactions
|
||
| next_instr = _Py_jit_entry((EXECUTOR), frame, stack_pointer, tstate); \ | ||
| frame = tstate->current_frame; \ | ||
| stack_pointer = _PyFrame_GetStackPointer(frame); \ | ||
| Py_DECREF(EXECUTOR); \ | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy should we decref it here?
Sorry, something went wrong.
All reactions
|
||
| if (next_instr == NULL) { \ | ||
| next_instr = frame->instr_ptr; \ | ||
| JUMP_TO_LABEL(error); \ | ||
| Expand Down Expand Up | @@ -413,4 +413,3 @@ check_periodics(PyThreadState *tstate) { | |
| } | ||
| return 0; | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1202,6 +1202,7 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil | |
| if (executor == NULL) { | ||
| return NULL; | ||
| } | ||
| _PyObject_GC_TRACK(executor); | ||
|
|
||
| /* Initialize exits */ | ||
| _PyExecutorObject *cold = _PyExecutor_GetColdExecutor(); | ||
| Expand Down Expand Up | @@ -1257,7 +1258,6 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil | |
| return NULL; | ||
| } | ||
| #endif | ||
| _PyObject_GC_TRACK(executor); | ||
| return executor; | ||
| } | ||
|
|
||
| Expand Down Expand Up | @@ -1507,6 +1507,7 @@ _PyExecutor_GetColdExecutor(void) | |
| if (cold == NULL) { | ||
| Py_FatalError("Cannot allocate core JIT code"); | ||
| } | ||
| _PyObject_GC_TRACK(cold); | ||
|
Comment thread
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis is incorrect. The executor is immortal for now. No this was correct, my bad. I didn't read the function correctly. The problem is that we're setting it immortal afterwards and I'm not sure it will be happy.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGood point, thanks for the correction. The intent was to track it for consistency immediately after allocation. My assumption is the GC correctly handles a tracked object that later becomes immortal. Is that a safe assumption, or should we explicitly _PyObject_GC_UNTRACK it just before immortalization?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThat I don't know. The problem here is whether we want an immortal cold executor or not. That's why I wanted to wait for Mark's output here, and didn't write a PR already.
Sorry, something went wrong.
All reactions
|
||
| ((_PyUOpInstruction *)cold->trace)->opcode = _COLD_EXIT; | ||
| #ifdef _Py_JIT | ||
| cold->jit_code = NULL; | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIs it just to hold a reference to the executor?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.