Skip to content

gh-144513: Skip critical section locking during stop-the-world#144524

Open
colesbury wants to merge 2 commits intopython:mainfrom
colesbury:gh-144513-critical-section-stw
Open

gh-144513: Skip critical section locking during stop-the-world#144524
colesbury wants to merge 2 commits intopython:mainfrom
colesbury:gh-144513-critical-section-stw

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Feb 5, 2026

When the interpreter is in a stop-the-world pause, critical sections don't need to acquire locks since no other threads can be running. This avoids a potential deadlock where lock fairness hands off ownership to a thread that has already suspended for stop-the-world.

When the interpreter is in a stop-the-world pause, critical sections
don't need to acquire locks since no other threads can be running.
This avoids a potential deadlock where lock fairness hands off ownership
to a thread that has already suspended for stop-the-world.
@colesbury
Copy link
Contributor Author

A few notes:

  • Mostly written by Claude code
  • Test passes on PR and would deadlock on main without the associated fix
  • Part of the motivation is making frame locals (framelocalsproxy) access thread-safe. Some of the time we will want to use a STW pause, and allowing the existing critical sections within that pause will make the modifications simpler

@colesbury colesbury marked this pull request as ready for review February 5, 2026 18:45
@colesbury colesbury requested review from Yhg1s and mpage February 5, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant