Skip to content

gh-155519: fix data-race for Context.ctx_vars - #155522

Merged
kumaraditya303 merged 2 commits into
python:mainfrom
nascheme:gh-155519-ctx-vars-race
Aug 15, 2026
Merged

kumaraditya303 merged 2 commits into
python:mainfrom
nascheme:gh-155519-ctx-vars-race

Conversation

@nascheme

@nascheme nascheme commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

The HAMT held by a context is immutable, but the pointer to it is not: contextvar_set() and contextvar_del() install a new HAMT and drop the reference to the previous one. Use critical sections to ensure ordering in the free-threaded build.

The HAMT held by a context is immutable, but the pointer to it is not:
contextvar_set() and contextvar_del() install a new HAMT and drop the
reference to the previous one.  Use critical sections to ensure
ordering in the free-threaded build.
@kumaraditya303
kumaraditya303 merged commit 9ee248c into python:main Aug 15, 2026
58 checks passed
@kumaraditya303 kumaraditya303 added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Aug 16, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @nascheme for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @nascheme for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 16, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 16, 2026
@bedevere-app

bedevere-app Bot commented Aug 16, 2026

Copy link
Copy Markdown

GH-155893 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Aug 16, 2026
hugovk pushed a commit that referenced this pull request Aug 19, 2026
…5893)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
kumaraditya303 pushed a commit that referenced this pull request Aug 20, 2026
…5892)

gh-155519: fix data-race for Context.ctx_vars (GH-155522)
(cherry picked from commit 9ee248c)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants