[3.14] gh-136396: Include instrumentation when creating new copies of… · python/cpython@9ae74e9 · GitHub
Skip to content

Commit 9ae74e9

Browse files
miss-islingtonmpagekumaraditya303
authored
[3.14] gh-136396: Include instrumentation when creating new copies of the bytecode (GH-136525) (GH-136657)
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: instrumentation and new bytecode creation cannot happen concurrently. Instrumentation requires that either the world is stopped or the code object's per-object lock is held and new bytecode creation requires holding the code object's per-object lock. (cherry picked from commit d995922) Co-authored-by: mpage <mpage@meta.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
1 parent c939963 commit 9ae74e9

3 files changed

Lines changed: 161 additions & 1 deletion

File tree

‎Lib/test/test_free_threading/test_monitoring.py‎

Lines changed: 141 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix issue where per-thread bytecode was not instrumented for newly created
2+
threads.

‎Objects/codeobject.c‎

Lines changed: 18 additions & 1 deletion

0 commit comments

Comments
 (0)