-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-107265: Fix initialize/remove_tools for ENTER_EXECUTOR case #108482
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -566,7 +566,12 @@ de_instrument(PyCodeObject *code, int i, int event) | |
_Py_CODEUNIT *instr = &_PyCode_CODE(code)[i]; | ||
uint8_t *opcode_ptr = &instr->op.code; | ||
int opcode = *opcode_ptr; | ||
assert(opcode != ENTER_EXECUTOR); | ||
if (opcode == ENTER_EXECUTOR) { | ||
int oparg = instr->op.arg; | ||
_PyExecutorObject *exec = code->co_executors->executors[oparg]; | ||
opcode_ptr = &exec->vm_data.opcode; | ||
opcode = *opcode_ptr; | ||
} | ||
if (opcode == INSTRUMENTED_LINE) { | ||
opcode_ptr = &code->_co_monitoring->lines[i].original_opcode; | ||
opcode = *opcode_ptr; | ||
|
@@ -575,6 +580,7 @@ de_instrument(PyCodeObject *code, int i, int event) | |
opcode_ptr = &code->_co_monitoring->per_instruction_opcodes[i]; | ||
opcode = *opcode_ptr; | ||
} | ||
assert(opcode != ENTER_EXECUTOR); | ||
corona10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int deinstrumented = DE_INSTRUMENT[opcode]; | ||
if (deinstrumented == 0) { | ||
return; | ||
|
@@ -711,7 +717,21 @@ remove_tools(PyCodeObject * code, int offset, int event, int tools) | |
assert(event != PY_MONITORING_EVENT_LINE); | ||
assert(event != PY_MONITORING_EVENT_INSTRUCTION); | ||
assert(PY_MONITORING_IS_INSTRUMENTED_EVENT(event)); | ||
assert(opcode_has_event(_Py_GetBaseOpcode(code, offset))); | ||
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. This is also correct, provided the assertion 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. Hmm, it will guarantee that the opcode is not ENTER_EXECUTOR? |
||
_Py_CODEUNIT co_instr = _PyCode_CODE(code)[offset]; | ||
uint8_t co_code = co_instr.op.code; | ||
uint8_t co_arg = co_instr.op.arg; | ||
if (co_code == ENTER_EXECUTOR) { | ||
_PyExecutorObject *exec = code->co_executors->executors[co_arg]; | ||
assert(exec != NULL); | ||
assert(exec->vm_data.opcode != ENTER_EXECUTOR); | ||
corona10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
co_code = _PyOpcode_Deopt[exec->vm_data.opcode]; | ||
co_arg = exec->vm_data.oparg; | ||
} | ||
else { | ||
co_code = _Py_GetBaseOpcode(code, offset); | ||
} | ||
assert(co_code != ENTER_EXECUTOR); | ||
assert(opcode_has_event(co_code)); | ||
corona10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_PyCoMonitoringData *monitoring = code->_co_monitoring; | ||
if (monitoring && monitoring->tools) { | ||
monitoring->tools[offset] &= ~tools; | ||
|
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.
This assertion is correct. Please don't remove assertions, unless you are really sure that they are incorrect.
ENTER_EXECUTOR
should never have associated instrumentation.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.
It was moved to L574, it will be the same effect no?