Uh oh!
There was an error while loading. Please reload this page.
gh-151593: Fix dead lock in PyDict insert_split_key() - #152200
Conversation
Do not hold LOCK_KEYS() lock when calling PyType_Modified() to avoid a deadlock. Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
vstinner
commented
Jun 25, 2026
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). |
vstinner
commented
Jun 25, 2026
@dpdani@colesbury@nascheme: Would you mind to review this fix? |
dpdani
left a comment
There was a problem hiding this comment.
I'd add a comment, but otherwise LGTM 👍
Uh oh!
There was an error while loading. Please reload this page.
vstinner
commented
Jun 25, 2026
@dpdani: I added a comment on LOCK_KEYS() based on previous comments on pull requests and issues. Does it look good to you? |
vstinner
commented
Jun 25, 2026
Merged. Thanks for reviews! |
Revert commits: gh-151593: Fix dead lock in PyDict insert_split_key() (#152200) gh-150490: Raise PyType_Modified for insertion into split dictionary (#150489) For gh-150489, it violates locking discipline and results in deadlocks, gh-151593 is an example of it being hit in CI. The attempted fixgh-152200 avoids the deadlock but introduces a data-race. The race window is small but can be triggered with pure Python code.
Do not hold LOCK_KEYS() lock when calling PyType_Modified() to avoid a deadlock.