Skip to content

[3.14] gh-159244: Fix crash in dict() on a concurrently mutated key/value pair (GH-159245) - #160587

Merged
methane merged 1 commit into
python:3.14from
methane:backport-eaab974-3.14
Oct 24, 2026
Merged

methane merged 1 commit into
python:3.14from
methane:backport-eaab974-3.14

Conversation

@methane

@methane methane commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

In the free-threaded build, dict() and dict.update() checked that a
list key/value pair had two items and then read them with borrowed
references without holding its lock, so another thread could empty
the list in between and the items were read from a freed or NULL
array.
(cherry picked from commit eaab974)

Co-authored-by: Christian Aurich Zanettini Martins christian.aurichzm@gmail.com

The test-file conflict was resolved by adding only this regression test to 3.14 and importing Event. The C change is unchanged from the original commit.

Validation: free-threaded debug build; test_dict, test_capi.test_dict, and test_free_threading.test_dict (161 tests passed).

… key/value pair (pythonGH-159245)

In the free-threaded build, dict() and dict.update() checked that a
list key/value pair had two items and then read them with borrowed
references without holding its lock, so another thread could empty
the list in between and the items were read from a freed or NULL
array.
(cherry picked from commit eaab974)

Co-authored-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
@methane
methane requested a review from markshannon as a code owner October 24, 2026 11:28
@bedevere-app bedevere-app Bot added topic-free-threading type-bug An unexpected behavior, bug, or error labels Oct 24, 2026
@methane
methane enabled auto-merge (squash) October 24, 2026 11:30
@methane
methane merged commit 224f1f1 into python:3.14 Oct 24, 2026
55 checks passed
@methane
methane deleted the backport-eaab974-3.14 branch October 24, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-free-threading type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants