Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-132917: Fix data race detected by tsan#133508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
(https://github.com/python/cpython/actions/runs/14857021107/job/41712717208?pr=133502):young.count can be modified by other threads even while the gcstate islocked.This is the simplest fix to (potentially) unblock beta 1, although thisparticular code path seems like it could just be an atomic swap followed byan atomic add, without having the lock at all.
Looks okay to me. |
53e6d76
intopython:mainUh oh!
There was an error while loading.Please reload this page.
nascheme commentedMay 6, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think the mutex is still needed to reliably update deferred_count. E.g. this interleaving loses the count value. T1: read and zero count, young_count =non zero |
Well, that's why I suggested a swap and anadd :) T1: read and zero count, young_count = non zero The two sequential operationsprobably aren't noticeably faster than the locking though. |
Uh oh!
There was an error while loading.Please reload this page.
Fix data race detected by tsan (https://github.com/python/cpython/actions/runs/14857021107/job/41712717208?pr=133502): young.count can be modified by other threads even while the gcstate is locked.
This is the simplest fix to (potentially) unblock beta 1, although this particular code path seems like it could just be an atomic swap followed by an atomic add, without having the lock at all.