Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.14] gh-137433: Fix deadlock with stop-the-world and daemon threads (gh-137735)#138965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
encukou merged 3 commits intopython:3.14frommiss-islington:backport-90fe325-3.14
Oct 7, 2025

Conversation

@miss-islington
Copy link
Contributor

@miss-islingtonmiss-islington commentedSep 16, 2025
edited by bedevere-appbot
Loading

There was a deadlock originally seen by Memray when a daemon thread
enabled or disabled profiling while the interpreter was shutting down.
I think this could also happen with garbage collection, but I haven't
seen that in practice.

The daemon thread could be hung while trying acquire the global rwmutex
that prevents overlapping global and per-interpreter stop-the-world events.
Since it already held the main interpreter's stop-the-world lock, it
also deadlocked the main thread, which is trying to perform interpreter
finalization.

Swap the order of lock acquisition to prevent this deadlock.
Additionally, refactor_PyParkingLot_Park so that the global buckets
hashtable is left in a clean state if the thread is hung in
PyEval_AcquireThread.
(cherry picked from commit90fe325)

Co-authored-by: Sam Grosscolesbury@gmail.com

…ythongh-137735)There was a deadlock originally seen by Memray when a daemon threadenabled or disabled profiling while the interpreter was shutting down.I think this could also happen with garbage collection, but I haven'tseen that in practice.The daemon thread could be hung while trying acquire the global rwmutexthat prevents overlapping global and per-interpreter stop-the-world events.Since it already held the main interpreter's stop-the-world lock, italso deadlocked the main thread, which is trying to perform interpreterfinalization.Swap the order of lock acquisition to prevent this deadlock.Additionally, refactor `_PyParkingLot_Park` so that the global bucketshashtable is left in a clean state if the thread is hung in`PyEval_AcquireThread`.(cherry picked from commit90fe325)Co-authored-by: Sam Gross <colesbury@gmail.com>
Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

Up to Hugo if he wants to include this in the RC.

@colesbury
Copy link
Contributor

I think this can wait until 3.14.1

@colesburycolesbury marked this pull request as draftSeptember 16, 2025 10:04
@colesbury
Copy link
Contributor

The added test is failing because we'll need to merge:

Before landing this PR to avoid an additional deadlock

@colesburycolesbury marked this pull request as ready for reviewOctober 7, 2025 17:55
@encukouencukou merged commite09f33e intopython:3.14Oct 7, 2025
52 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@colesburycolesburycolesbury approved these changes

@ZeroIntensityZeroIntensityZeroIntensity approved these changes

@kumaraditya303kumaraditya303kumaraditya303 approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

Assignees

@colesburycolesbury

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@miss-islington@colesbury@ZeroIntensity@kumaraditya303@encukou

[8]ページ先頭

©2009-2025 Movatter.jp