Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-139540: Fix executor deallocation crash when JIT compilation fails#139952
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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 |
|---|---|---|
| @@ -351,12 +351,12 @@ _PyFrame_SetStackPointer(frame, stack_pointer) | ||
| /* Tier-switching macros. */ | ||
| #define TIER1_TO_TIER2(EXECUTOR) \ | ||
| #define TIER1_TO_TIER2(EXECUTOR) \ | ||
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. Why was this changed? please revert. | ||
| do{\ | ||
| OPT_STAT_INC(traces_executed); \ | ||
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. Why was this changed? please revert. | ||
| next_instr = _Py_jit_entry((EXECUTOR), frame, stack_pointer, tstate); \ | ||
| frame = tstate->current_frame; \ | ||
| stack_pointer = _PyFrame_GetStackPointer(frame); \ | ||
| Py_DECREF(EXECUTOR); \ | ||
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. Why should we decref it here? | ||
| if (next_instr == NULL){\ | ||
| next_instr = frame->instr_ptr; \ | ||
| JUMP_TO_LABEL(error); \ | ||
| @@ -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.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); | ||
| @@ -1257,7 +1258,6 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil | ||
| return NULL; | ||
| } | ||
| #endif | ||
| _PyObject_GC_TRACK(executor); | ||
| return executor; | ||
| } | ||
| @@ -1507,6 +1507,7 @@ _PyExecutor_GetColdExecutor(void) | ||
| if (cold == NULL){ | ||
| Py_FatalError("Cannot allocate core JIT code"); | ||
| } | ||
| _PyObject_GC_TRACK(cold); | ||
Member
| ||
| ((_PyUOpInstruction *)cold->trace)->opcode = _COLD_EXIT; | ||
| #ifdef _Py_JIT | ||
| cold->jit_code = NULL; | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Is it just to hold a reference to the executor?