Skip to content

gh-137400: Stop the world when swapping profile functions - #137472

Closed
godlygeek wants to merge 2 commits into
python:mainfrom
godlygeek:fix_setprofileallthreads_race
Closed

godlygeek wants to merge 2 commits into
python:mainfrom
godlygeek:fix_setprofileallthreads_race

Conversation

@godlygeek

@godlygeek godlygeek commented Aug 6, 2025 •

Copy link
Copy Markdown
Contributor

One thread's profile function or profile object can be changed from another thread, for instance by sys._setprofileallthreads. This can lead to crashes unless the two threads are synchronized. We need a stop-the-world to ensure that the thread whose profile function or profile object is being changed is in a state where it's not in the middle of using either of those pointers.

One thread's profile function or profile object can be changed from
another thread, for instance by `sys._setprofileallthreads`. This can
lead to crashes unless the two threads are synchronized. We need
a stop-the-world to ensure that the thread whose profile function or
profile object is being changed is in a state where it's not in the
middle of using either of those pointers.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek

Copy link
Copy Markdown
Contributor Author
@godlygeek

Copy link
Copy Markdown
Contributor Author

Ah, nevermind, I see @colesbury beat me to it with #137471 and added a test to boot.

@godlygeek godlygeek closed this Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant