GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.14] gh-151518: Avoid STW starvation of attaching threads (GH-152826) by tpn · Pull Request #158187 · python/cpython

Conversation

@tpn

@tpn tpn commented Sep 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Backport of gh-152826, merged as f156510, for gh-151518.

A tight loop of stop-the-world pauses can repeatedly suspend a thread trying to reattach after sleeping, preventing it from returning and stopping the loop. This was found during intentional numba-cuda GC stress on many-core machines. The fix preserves active attach waiters across successive pauses so they have a chance to run.

This branch predates gh-157839, so the waiter-aware resume operation is a private helper in pystate.c. The attachment changes, regression test, and guard that avoids blocking waits on WASI are carried over from the merged fix.

Validation:

  • Free-threaded debug and TSan: all 31 focused threading, GC, and asyncio tests passed.
  • With only the test changes, the unfixed branch hits the 30-second watchdog with 4 and 64 CPUs. The backport passes three runs each with 1, 4, and 64 CPUs.
  • Internal C API helper tests, including test_stop_the_world: all 16 passed in the ordinary GIL build and all 13 available tests passed on WASI, using this branch's SDK 24 and Wasmtime 38.0.3 toolchain.

Rebased onto current 3.14 to include the Windows toolset fix from gh-158188. The backport patch is unchanged; after rebuilding, all 31 focused free-threaded debug tests passed again. Fresh CI is pending, including both Windows ARM64 configurations that previously failed before compilation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tpn
tpn requested a review from ericsnowcurrently as a code owner September 25, 2026 18:37
@bedevere-app bedevere-app Bot mentioned this pull request Sep 25, 2026
Free-threaded CPython can starve a thread reattaching during repeated stop-the-world GC #151518
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 25, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Sep 25, 2026
gh-151518: Avoid STW starvation of attaching threads #152826
Merged
@tpn
[3.14] pythongh-151518: Avoid STW starvation of attaching threads
3e1a1e6
Preserve active attach waiters across successive stop-the-world pauses.
Adapt the resume transition to the 3.14 stop-the-world implementation
and include the regression test and free-threaded test helper.

(cherry picked from commit f156510)
@tpn
tpn force-pushed the codex/gh-151518-backport-314 branch from 6cf40ec to 3e1a1e6 Compare September 28, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@tpn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.