Skip to content

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Dec 19, 2025

TSan treats compare-exchanges that fail as if they are writes so there is a false positive with the read of gi_frame_state in gen_close.

TSan treats compare-exchanges that fail as if they are writes
so there is a false positive with the read of gi_frame_state in
gen_close.
@colesbury
Copy link
Contributor Author

I keep making this same mistake. This Should fix https://github.com/python/cpython/actions/runs/20383044472/job/58577900039?pr=142957:

WARNING: ThreadSanitizer: data race (pid=21767)
  Read of size 1 at 0x7f9ccb6ceb63 by thread T475:
    #0 gen_clear_frame /home/runner/work/cpython/cpython/Objects/genobject.c:156:5 (python+0x2afcde) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)
    #1 gen_close /home/runner/work/cpython/cpython/Objects/genobject.c (python+0x2ac1d1) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)
    #2 method_vectorcall_NOARGS /home/runner/work/cpython/cpython/Objects/descrobject.c:448:24 (python+0x289784) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)
    #3 _PyObject_VectorcallTstate /home/runner/work/cpython/cpython/./Include/internal/pycore_call.h:136:11 (python+0x26a6ab) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)
...

  Previous atomic write of size 1 at 0x7f9ccb6ceb63 by thread T472:
    #0 _Py_atomic_compare_exchange_int8 /home/runner/work/cpython/cpython/./Include/cpython/pyatomic_gcc.h:75:10 (python+0x2b0751) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)
    #1 gen_send_ex /home/runner/work/cpython/cpython/Objects/genobject.c:327:15 (python+0x2b0751)
    #2 gen_iternext /home/runner/work/cpython/cpython/Objects/genobject.c:720:9 (python+0x2acf7c) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)
    #3 _PyForIter_VirtualIteratorNext /home/runner/work/cpython/cpython/Python/ceval.c:4056:24 (python+0x520502) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)
    #4 _PyEval_EvalFrameDefault /home/runner/work/cpython/cpython/Python/generated_cases.c.h:5500:36 (python+0x4f33f8) (BuildId: edcf083ae7c4567c86d1e5be11648e5caf6d5047)

@colesbury colesbury merged commit 4ea3c1a into python:main Dec 19, 2025
53 of 54 checks passed
@colesbury colesbury deleted the gh-120321-gen-atomic-close branch December 19, 2025 22:33
cocolato pushed a commit to cocolato/cpython that referenced this pull request Dec 22, 2025
…142995)

TSan treats compare-exchanges that fail as if they are writes
so there is a false positive with the read of gi_frame_state in
gen_close.
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