Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
Yhg1s merged 1 commit intopython:mainfromYhg1s:gc-rss-threadsafety
May 6, 2025

Conversation

Yhg1s
Copy link
Member

@Yhg1sYhg1s commentedMay 6, 2025
edited by bedevere-appbot
Loading

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.

(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.
@nascheme
Copy link
Member

Looks okay to me.

@Yhg1sYhg1senabled auto-merge (squash)May 6, 2025 11:22
@Yhg1sYhg1s merged commit53e6d76 intopython:mainMay 6, 2025
42 checks passed
@nascheme
Copy link
Member

nascheme commentedMay 6, 2025
edited
Loading

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
T2: read and zero count, young_count = 0
T1: read deferred_count
T2: read deferred_count
T1: write deferred_count + young_count
T2: write deferred_count + young_count

@Yhg1s
Copy link
MemberAuthor

Well, that's why I suggested a swap and anadd :)

T1: read and zero count, young_count = non zero
T2: read and zero count, young_count = 0
T1: add young_count to deferred_count
T2: add 0 to deferred_count

The two sequential operationsprobably aren't noticeably faster than the locking though.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@naschemenaschemeAwaiting requested review from nascheme

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Yhg1s@nascheme

[8]ページ先頭

©2009-2025 Movatter.jp