Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-107265: Fix code_richcompare for ENTER_EXECUTOR case#108165

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

Merged
corona10 merged 4 commits intopython:mainfromcorona10:gh-107265
Aug 21, 2023

Conversation

corona10
Copy link
Member

@corona10corona10 commentedAug 20, 2023
edited
Loading

@corona10corona10 changed the titlegh-107265: Fix code_richcompare to lookup actual opcode when ENTER_EX…gh-107265: Fix code_richcompare for ENTER_EXECUTOR caseAug 20, 2023
Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LG, but could you add a test for this? You could add it totest_capi/test_misc.py inTestOptimizerAPI.

corona10 reacted with thumbs up emoji
@corona10
Copy link
MemberAuthor

corona10 commentedAug 21, 2023
edited
Loading

LG, but could you add a test for this? You could add it to test_capi/test_misc.py in TestOptimizerAPI.

Thanks, I added the test, and if I understand the intention correctly.
co_instr.op.arg andcp_instr.op.arg should also be updated.
If not, comparingco_instr.cache == cp_instr.cache will be failed anyway.

Please let me know if I understand wrongly.

@corona10
Copy link
MemberAuthor

corona10 commentedAug 21, 2023
edited
Loading

pydoc test failure is unrelated to this PR, I checked it locally and asked to Discord too

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, thearg must also be restored, since it is overwritten (with the index of the executor to be used in this code object's array of executors). So it looks like writing the test was useful!

corona10 reacted with thumbs up emoji
@corona10corona10enabled auto-merge (squash)August 21, 2023 05:03
@corona10corona10 merged commit4fdf3fd intopython:mainAug 21, 2023
@corona10corona10 deleted the gh-107265 branchAugust 21, 2023 05:50
if (co_instr.op.code == ENTER_EXECUTOR) {
const int exec_index = co_instr.op.arg;
_PyExecutorObject *exec = co->co_executors->executors[exec_index];
co_instr.op.code = exec->vm_data.opcode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Comparing two code objects must not modify the code object.

The interaction between executor, the specializer and instrumentation is subtle and likely to break without care.
This will leak executors, as it flip-flops betweenJUMP_BACKWARDS andENTER_EXECUTOR, or worse if an optimizer assumes that a single instruction will only be seen once.

if (cp_instr.op.code == ENTER_EXECUTOR) {
const int exec_index = cp_instr.op.arg;
_PyExecutorObject *exec = cp->co_executors->executors[exec_index];
cp_instr.op.code = exec->vm_data.opcode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Likewise

@markshannon
Copy link
Member

Please revert this. It will leak, and may not be safe.

@markshannon
Copy link
Member

#101346

@gvanrossum
Copy link
Member

@corona10 We can fix this in the hash PR you are working on.

@corona10
Copy link
MemberAuthor

@corona10 We can fix this in the hash PR you are working on.

Okay got it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@markshannonmarkshannonmarkshannon left review comments

@gvanrossumgvanrossumgvanrossum approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@corona10@markshannon@gvanrossum@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp