Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-109052: Use the base opcode when comparing code objects#109107
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 ourterms of service andprivacy 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 fromall 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 @@ | ||
| Use the base opcode when comparing code objects to avoid interference from instrumentation |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1797,28 +1797,26 @@ code_richcompare(PyObject *self, PyObject *other, int op) | ||
| for (int i = 0; i < Py_SIZE(co); i++) { | ||
| _Py_CODEUNIT co_instr = _PyCode_CODE(co)[i]; | ||
| _Py_CODEUNIT cp_instr = _PyCode_CODE(cp)[i]; | ||
| uint8_t co_code =_Py_GetBaseOpcode(co, i); | ||
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. I am not sure that calling this API at this moment is correct. See L1812, what will happen 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. Or move co_code or cp_code = _PyOpcode_Deopt[cocode or cp_code]; only if cp_code or co_code is ENTER_EXECUTOR at L1805 or L1814 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.
I think we should change this code to be exactly the same as what I also think that 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. FYI, If we decide to fix 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. And maybe we can close#107265 in one short. 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. IIRC there are also cases where we absolutely want the actual opcode, so in those cases we still need to handle ENTER_EXECUTOR explicitly. But yeah, fixing this in 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. IMPORTANT! Do not attempt to "fix" | ||
| uint8_t co_arg = co_instr.op.arg; | ||
| uint8_t cp_code =_Py_GetBaseOpcode(cp, i); | ||
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. ditto | ||
| uint8_t cp_arg = cp_instr.op.arg; | ||
| if (co_code == ENTER_EXECUTOR) { | ||
| const int exec_index = co_arg; | ||
| _PyExecutorObject *exec = co->co_executors->executors[exec_index]; | ||
| co_code =_PyOpcode_Deopt[exec->vm_data.opcode]; | ||
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. Nice catch. I think I agree with@gvanrossum though that MemberAuthor 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. Yes, I can work on that. MemberAuthor 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. So@gvanrossum mentioned we should NOT handle 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. See the list of bullets ingh-107265. | ||
| co_arg = exec->vm_data.oparg; | ||
| } | ||
| assert(co_code != ENTER_EXECUTOR); | ||
| if (cp_code == ENTER_EXECUTOR) { | ||
| const int exec_index = cp_arg; | ||
| _PyExecutorObject *exec = cp->co_executors->executors[exec_index]; | ||
| cp_code =_PyOpcode_Deopt[exec->vm_data.opcode]; | ||
| cp_arg = exec->vm_data.oparg; | ||
| } | ||
| assert(cp_code != ENTER_EXECUTOR); | ||
| if (co_code != cp_code || co_arg != cp_arg) { | ||
| goto unequal; | ||