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-136396: Include instrumentation when creating new copies of the bytecode#136525

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
mpage merged 3 commits intopython:mainfrommpage:gh-136396-fix-instrumentation
Jul 14, 2025

Conversation

mpage
Copy link
Contributor

@mpagempage commentedJul 10, 2025
edited by bedevere-appbot
Loading

Previously, we assumed that instrumentation would happen for all copies of the bytecode if the instrumentation version on the code object didn't match the per-interpreter instrumentation version. That assumption was incorrect: instrumentation will exit early if there are no new "events," even if there is an instrumentation version mismatch.

To fix this, include the instrumented opcodes when creating new copies of the bytecode, rather than replacing them with their uninstrumented variants. I don't think we have to worry about races between instrumentation and creating new copies of the bytecode as they cannot happen concurrently. Instrumentation requires that either the world is stopped or the code object's per-object lock is held, while new bytecode creation requires holding the code object's per-object lock.

Previously, we assumed that instrumentation would happen for all copies ofthe bytecode if the instrumentation version on the code object didn't matchthe per-interpreter instrumentation version. That assumption was incorrect:instrumentation will exit early if there are no new "events," even if thereis an instrumentation version mismatch.To fix this, include the instrumented opcodes when creating new copies ofthe bytecode, rather than replacing them with their uninstrumented variants.I don't think we have to worry about races between instrumentation and creatingnew copies of the bytecode: instrumentation and new bytecode creation cannot happenconcurrently. Instrumentation requires that either the world is stopped or thecode object's per-object lock is held and new bytecode creation requires holdingthe code object's per-object lock.
@mpagempage marked this pull request as ready for reviewJuly 10, 2025 23:24
@mpagempage requested review fromcolesbury andYhg1sJuly 10, 2025 23:24
@mpagempage merged commitd995922 intopython:mainJul 14, 2025
41 checks passed
@mpagempage added the needs backport to 3.14bugs and security fixes labelJul 14, 2025
@miss-islington-app
Copy link

Thanks@mpage for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJul 14, 2025
…the bytecode (pythonGH-136525)Previously, we assumed that instrumentation would happen for all copies ofthe bytecode if the instrumentation version on the code object didn't matchthe per-interpreter instrumentation version. That assumption was incorrect:instrumentation will exit early if there are no new "events," even if thereis an instrumentation version mismatch.To fix this, include the instrumented opcodes when creating new copies ofthe bytecode, rather than replacing them with their uninstrumented variants.I don't think we have to worry about races between instrumentation and creatingnew copies of the bytecode: instrumentation and new bytecode creation cannot happenconcurrently. Instrumentation requires that either the world is stopped or thecode object's per-object lock is held and new bytecode creation requires holdingthe code object's per-object lock.(cherry picked from commitd995922)Co-authored-by: mpage <mpage@meta.com>
@bedevere-app
Copy link

GH-136657 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJul 14, 2025
colesbury pushed a commit that referenced this pull requestJul 15, 2025
… the bytecode (GH-136525) (GH-136657)Previously, we assumed that instrumentation would happen for all copies ofthe bytecode if the instrumentation version on the code object didn't matchthe per-interpreter instrumentation version. That assumption was incorrect:instrumentation will exit early if there are no new "events," even if thereis an instrumentation version mismatch.To fix this, include the instrumented opcodes when creating new copies ofthe bytecode, rather than replacing them with their uninstrumented variants.I don't think we have to worry about races between instrumentation and creatingnew copies of the bytecode: instrumentation and new bytecode creation cannot happenconcurrently. Instrumentation requires that either the world is stopped or thecode object's per-object lock is held and new bytecode creation requires holdingthe code object's per-object lock.(cherry picked from commitd995922)Co-authored-by: mpage <mpage@meta.com>Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@Yhg1sYhg1sYhg1s approved these changes

@colesburycolesburycolesbury approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

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

Successfully merging this pull request may close these issues.

3 participants
@mpage@colesbury@Yhg1s

[8]ページ先頭

©2009-2025 Movatter.jp