gh-151593: Fix dead lock in PyDict insert_split_key()#152200
Open
vstinner wants to merge 2 commits into
Open
Conversation
Do not hold LOCK_KEYS() lock when calling PyType_Modified() to avoid a deadlock. Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Member
Author
|
On Python built with
It only takes 1 or 2 iterations to trigger the deadlock. With this change, I can no longer reproduce the deadlock: the test is running for 5 minutes (test_abc passed 35 times in a row). |
Member
Author
|
@dpdani @colesbury @nascheme: Would you mind to review this fix? |
dpdani
reviewed
Jun 25, 2026
dpdani
left a comment
Contributor
There was a problem hiding this comment.
I'd add a comment, but otherwise LGTM 👍
Member
Author
|
@dpdani: I added a comment on LOCK_KEYS() based on previous comments on pull requests and issues. Does it look good to you? |
colesbury
approved these changes
Jun 25, 2026
colesbury
left a comment
Contributor
There was a problem hiding this comment.
Thanks for fixing this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Do not hold LOCK_KEYS() lock when calling PyType_Modified() to avoid a deadlock.