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

Commit53e6d76

Browse files
authored
gh-132917: Fix data race detected by tsan (#133508)
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 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.
1 parent296cd12 commit53e6d76

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

‎Python/gc_free_threading.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,10 +2074,9 @@ gc_should_collect_mem_usage(GCState *gcstate)
20742074
// clear the young object count so we don't check memory usage again
20752075
// on the next call to gc_should_collect().
20762076
PyMutex_Lock(&gcstate->mutex);
2077+
intyoung_count=_Py_atomic_exchange_int(&gcstate->young.count,0);
20772078
_Py_atomic_store_ssize_relaxed(&gcstate->deferred_count,
2078-
gcstate->deferred_count+
2079-
gcstate->young.count);
2080-
_Py_atomic_store_int(&gcstate->young.count,0);
2079+
gcstate->deferred_count+young_count);
20812080
PyMutex_Unlock(&gcstate->mutex);
20822081
return false;
20832082
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp