Skip to content

gh-148393: Use acquire load for _ma_watcher_tag in dict notify event#148509

Merged
colesbury merged 1 commit intopython:mainfrom
colesbury:gh-148393-notify-acquire
Apr 13, 2026
Merged

gh-148393: Use acquire load for _ma_watcher_tag in dict notify event#148509
colesbury merged 1 commit intopython:mainfrom
colesbury:gh-148393-notify-acquire

Conversation

@colesbury
Copy link
Copy Markdown
Contributor

@colesbury colesbury commented Apr 13, 2026

The watcher-bits read in _PyDict_NotifyEvent needs to use acquire to synchronize with the release from PyDict_Watch so that the callback publication is visible before the callback is invoked.

…event

The watcher-bits read in _PyDict_NotifyEvent needs to use acquire to
synchronize with the release from PyDict_Watch so that the callback
publication is visible before the callback is invoked.
@colesbury
Copy link
Copy Markdown
Contributor Author

I missed this before, but I think we want to use acquire here so that any setup done before PyDict_Watch is visible (i.e., is ordered before) in the watcher notification, which may occur in a different thread.

@colesbury colesbury merged commit 19f96f9 into python:main Apr 13, 2026
61 checks passed
@miss-islington-app
Copy link
Copy Markdown

Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@colesbury colesbury deleted the gh-148393-notify-acquire branch April 13, 2026 18:11
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 13, 2026
…event (pythongh-148509)

The watcher-bits read in _PyDict_NotifyEvent needs to use acquire to
synchronize with the release from PyDict_Watch so that the callback
publication is visible before the callback is invoked.
(cherry picked from commit 19f96f9)

Co-authored-by: Sam Gross <[email protected]>
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 13, 2026

GH-148512 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 Apr 13, 2026
colesbury added a commit that referenced this pull request Apr 13, 2026
… event (gh-148509) (#148512)

The watcher-bits read in _PyDict_NotifyEvent needs to use acquire to
synchronize with the release from PyDict_Watch so that the callback
publication is visible before the callback is invoked.
(cherry picked from commit 19f96f9)

Co-authored-by: Sam Gross <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants