]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-136396: Include instrumentation when creating new copies of the bytecode...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 15 Jul 2025 15:10:37 +0000 (17:10 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Jul 2025 15:10:37 +0000 (11:10 -0400)
commit9ae74e94a06865aee96827838ce16c8924cbe86f
tree71932366c8f66e7d486570a471fd147d48cbf09b
parentc939963b53600062f0978c99559e22ab39135402
[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 d995922198304a6de19ac1bec3e36d1e886d8468)

Co-authored-by: mpage <mpage@meta.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Lib/test/test_free_threading/test_monitoring.py
Misc/NEWS.d/next/Core_and_Builtins/2025-07-10-15-53-16.gh-issue-136525.xAko0e.rst [new file with mode: 0644]
Objects/codeobject.c