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 — gh-128639: Don't assume one thread in subinterpreter finalization with fixed daemon thread support by ZeroIntensity · Pull Request #134606 · python/cpython

Conversation

@ZeroIntensity

@ZeroIntensity ZeroIntensity commented May 24, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This is a reapplication of #128640, with daemon thread hanging fixed.

The key part that I was missing was this:

for (PyThreadState *p = list; p != NULL; p = p->next) {
    _PyThreadState_SetShuttingDown(p);
}

My fix predated these lines, so it didn't make it in originally.

The reason this only failed on the iOS buildbots was because they're single-process. Out of random choice, I picked 100 seconds as the sleep time, but since the process would exit before that 100 seconds was over on all the other buildbots, there wasn't any problem. On iOS, the test suite continued to run in the same process after the 100 seconds were up, so the daemon threads would start trying to run again under a deallocated interpreter, causing all sorts of weird crashes.

  • Issue: Subinterpreters don't properly clean up threads #128639

Sorry, something went wrong.

Uh oh!

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

All reactions
ZeroIntensity added 2 commits May 21, 2025 20:17
@ZeroIntensity
Reapply "pythongh-128639: Don't assume one thread in subinterpreter f…
b14aa73
…inalization (pythongh-128640)" (pythongh-134256)

This reverts commit 27bd082.
@ZeroIntensity
Fix daemon thread shutdown.
91d94d9
@ZeroIntensity
ZeroIntensity requested a review from ericsnowcurrently as a code owner May 24, 2025 00:27
@bedevere-app bedevere-app Bot mentioned this pull request May 24, 2025
Subinterpreters don't properly clean up threads #128639
Closed
@bedevere-app bedevere-app Bot added the awaiting review label May 24, 2025
@ZeroIntensity ZeroIntensity added topic-subinterpreters 🔨 test-with-buildbots Test PR w/ buildbots; report in status section labels May 24, 2025
@bedevere-bot

This comment was marked as outdated.

Sign in to view
@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 24, 2025
@ZeroIntensity ZeroIntensity mentioned this pull request May 24, 2025
[3.14] gh-128639: Don't assume one thread in subinterpreter finalization (gh-128640) #134254
Closed
@ZeroIntensity ZeroIntensity added the needs backport to 3.14 bugs and security fixes label May 24, 2025
@ZeroIntensity
Stop the runtime instead of the interpreter.
a569355
@ZeroIntensity ZeroIntensity added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 24, 2025
@bedevere-bot

bedevere-bot commented May 24, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit a569355 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F134606%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 24, 2025
@ZeroIntensity
Merge branch 'main' into fix-subinterp-thread-shutdown
0146aec
@ZeroIntensity

This comment was marked as outdated.

Sign in to view
@ZeroIntensity

This comment was marked as outdated.

Sign in to view
@bedevere-bot

This comment was marked as outdated.

Sign in to view
@ZeroIntensity
Run the daemon thread test in a subprocess.
f85a291
@ZeroIntensity

ZeroIntensity commented May 25, 2025

Copy link
Copy Markdown
Member Author

!buildbot refleak

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented May 25, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit f85a291 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F134606%2Fmerge

The command will test the builders whose names match following regular expression: refleak

The builders matched are:

  • aarch64 Fedora Rawhide NoGIL refleaks PR
  • AMD64 Fedora Rawhide NoGIL refleaks PR
  • PPC64LE RHEL8 Refleaks PR
  • PPC64LE Fedora Rawhide NoGIL refleaks PR
  • PPC64LE CentOS9 Refleaks PR
  • s390x Fedora Rawhide NoGIL refleaks PR
  • AMD64 Fedora Stable Refleaks PR
  • AMD64 RHEL8 Refleaks PR
  • AMD64 Windows11 Refleaks PR
  • aarch64 Fedora Stable Refleaks PR
  • AMD64 Fedora Rawhide Refleaks PR
  • ARM64 MacOS M1 Refleaks NoGIL PR
  • aarch64 Fedora Rawhide Refleaks PR
  • aarch64 RHEL8 Refleaks PR
  • s390x RHEL8 Refleaks PR
  • s390x Fedora Rawhide Refleaks PR
  • AMD64 FreeBSD Refleaks PR
  • aarch64 CentOS9 Refleaks PR
  • AMD64 CentOS9 NoGIL Refleaks PR
  • PPC64LE Fedora Stable Refleaks PR
  • PPC64LE Fedora Rawhide Refleaks PR
  • s390x RHEL9 Refleaks PR
  • AMD64 CentOS9 Refleaks PR
  • s390x Fedora Stable Refleaks PR
All reactions

Sorry, something went wrong.

Uh oh!

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

@ZeroIntensity ZeroIntensity mentioned this pull request May 25, 2025
gh-134604: Fix tracemalloc crash with subinterpreters #134667
Closed
@ZeroIntensity

ZeroIntensity commented May 26, 2025

Copy link
Copy Markdown
Member Author

@ericsnowcurrently Yay, buildbots passed on this one!

All reactions

Sorry, something went wrong.

Uh oh!

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

ericsnowcurrently
ericsnowcurrently requested changes May 27, 2025
View reviewed changes

@ericsnowcurrently ericsnowcurrently left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like with gh-128640, mostly LGTM. I've left a few minor comments.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/pylifecycle.c Resolved

Uh oh!

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

Comment thread Python/pylifecycle.c Resolved

Uh oh!

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

Comment thread Lib/test/test_interpreters/test_api.py Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting review labels May 27, 2025
@bedevere-app

bedevere-app Bot commented May 27, 2025

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

ZeroIntensity and others added 2 commits May 27, 2025 11:12
@ZeroIntensity @ericsnowcurrently
Update Lib/test/test_interpreters/test_api.py
d287d54
Co-authored-by: Eric Snow <[email protected]>
@ZeroIntensity
Merge branch 'main' into fix-subinterp-thread-shutdown
fe7a342
ZeroIntensity added 2 commits June 8, 2025 17:03
@ZeroIntensity
Merge branch 'main' of https://github.com/python/cpython into fix-sub…
193c49a
…interp-thread-shutdown
@ZeroIntensity
Remove broken assertion.
62bd653
@ZeroIntensity
ZeroIntensity requested a review from markshannon as a code owner June 8, 2025 21:08
@ZeroIntensity

This comment has been minimized.

Sign in to view
@ZeroIntensity ZeroIntensity added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 8, 2025
@bedevere-bot

bedevere-bot commented Jun 8, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit 62bd653 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F134606%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 8, 2025
@ZeroIntensity
Avoid using list comprehensions in the tests.
b029dd5
These cause crashes due to an existing bug with subinterpreters.
@ZeroIntensity ZeroIntensity mentioned this pull request Jun 13, 2025
List comprehensions cause subinterpreter crashes #135450
Closed
@ZeroIntensity

ZeroIntensity commented Jun 17, 2025

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Jun 17, 2025
@bedevere-app

bedevere-app Bot commented Jun 17, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@ericsnowcurrently: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app
bedevere-app Bot requested a review from ericsnowcurrently June 17, 2025 19:04
@ZeroIntensity
Merge branch 'main' of https://github.com/python/cpython into fix-sub…
88b1cf6
…interp-thread-shutdown
@neonene neonene mentioned this pull request Aug 1, 2025
Assertion failure when interrupting active threads for subinterpreters #137295
Closed
ZeroIntensity added 2 commits September 15, 2025 04:48
@ZeroIntensity
Merge branch 'main' of https://github.com/python/cpython into fix-sub…
a8de87c
…interp-thread-shutdown
@ZeroIntensity
Merge branch 'main' into fix-subinterp-thread-shutdown
6acb265
ericsnowcurrently
ericsnowcurrently approved these changes Sep 17, 2025
View reviewed changes

@ericsnowcurrently ericsnowcurrently left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Sep 17, 2025
@ZeroIntensity
ZeroIntensity merged commit a648813 into python:main Sep 17, 2025
@ZeroIntensity
ZeroIntensity deleted the fix-subinterp-thread-shutdown branch September 17, 2025 15:14
@miss-islington-app

miss-islington-app Bot commented Sep 17, 2025

Copy link
Copy Markdown

Thanks @ZeroIntensity for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 17, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 17, 2025
@ZeroIntensity @miss-islington
pythongh-128639: Don't assume one thread in subinterpreter finalizati…
7b8c082
…on with fixed daemon thread support (pythonGH-134606)

This reapplies pythonGH-128640.
(cherry picked from commit a648813)

Co-authored-by: Peter Bierma <[email protected]>
@bedevere-app

bedevere-app Bot commented Sep 17, 2025

Copy link
Copy Markdown

GH-139050 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 17, 2025
ZeroIntensity added a commit that referenced this pull request Oct 7, 2025
@miss-islington @ZeroIntensity
[3.14] gh-128639: Don't assume one thread in subinterpreter finalizat…
cec4ddf
…ion with fixed daemon thread support (GH-134606) (GH-139050)

gh-128639: Don't assume one thread in subinterpreter finalization with fixed daemon thread support (GH-134606)

This reapplies GH-128640.
(cherry picked from commit a648813)

Co-authored-by: Peter Bierma <[email protected]>
@ZeroIntensity ZeroIntensity mentioned this pull request Oct 17, 2025
TSAN failure with free-threaded build, test_daemon_threads_fatal_error #140138
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently ericsnowcurrently approved these changes
@markshannon markshannon Awaiting requested review from markshannon

Uh oh!

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

Assignees

No one assigned

Labels

topic-subinterpreters

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.

3 participants

@ZeroIntensity @bedevere-bot @ericsnowcurrently
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.