]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-116818: Make `sys.settrace`, `sys.setprofile`, and monitoring thread-safe (#116775)
authorDino Viehland <dinoviehland@meta.com>
Fri, 19 Apr 2024 21:47:42 +0000 (14:47 -0700)
committerGitHub <noreply@github.com>
Fri, 19 Apr 2024 21:47:42 +0000 (14:47 -0700)
commit07525c9a85e7fa04db565c6e6e6605ff6099dcb7
treeb12112a245641172073d1f1df8212aa082ec8db8
parentb45af00bad3449b85c8f54ba7a9474ca1f52de69
gh-116818: Make `sys.settrace`, `sys.setprofile`, and monitoring thread-safe (#116775)

Makes sys.settrace, sys.setprofile, and monitoring generally thread-safe.

Mostly uses a stop-the-world approach and synchronization around the code object's _co_instrumentation_version.  There may be a little bit of extra synchronization around the monitoring data that's required to be TSAN clean.
18 files changed:
Include/cpython/pyatomic.h
Include/cpython/pyatomic_gcc.h
Include/cpython/pyatomic_msc.h
Include/cpython/pyatomic_std.h
Include/internal/pycore_ceval_state.h
Include/internal/pycore_gc.h
Include/internal/pycore_pyatomic_ft_wrappers.h
Lib/test/test_free_threading/__init__.py [new file with mode: 0644]
Lib/test/test_free_threading/test_monitoring.py [new file with mode: 0644]
Makefile.pre.in
Python/bytecodes.c
Python/ceval.c
Python/executor_cases.c.h
Python/generated_cases.c.h
Python/instrumentation.c
Python/legacy_tracing.c
Python/pystate.c
Tools/jit/template.c