GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-120321: Fix TSan reported race in gen_clear_frame by colesbury · Pull Request #142995 · python/cpython

Conversation

@colesbury

@colesbury colesbury commented Dec 19, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: SIGSEGV with generators in free-threaded build #120321

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@colesbury
pythongh-120321: Fix TSan reported race in gen_clear_frame
807c03f
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
colesbury requested a review from mpage December 19, 2025 22:06
@colesbury
colesbury requested a review from markshannon as a code owner December 19, 2025 22:06
@colesbury colesbury added skip news topic-free-threading labels Dec 19, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Dec 19, 2025
SIGSEGV with generators in free-threaded build #120321
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Dec 19, 2025
@colesbury

colesbury commented Dec 19, 2025

Copy link
Copy Markdown
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)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mpage
mpage approved these changes Dec 19, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Dec 19, 2025
@colesbury
colesbury merged commit 4ea3c1a into python:main Dec 19, 2025
53 of 54 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@colesbury
colesbury deleted the gh-120321-gen-atomic-close branch December 19, 2025 22:33
@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 19, 2025
cocolato pushed a commit to cocolato/cpython that referenced this pull request Dec 22, 2025
@colesbury @cocolato
pythongh-120321: Fix TSan reported race in gen_clear_frame (pythongh-…
91f4bbd
…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.
@colesbury colesbury mentioned this pull request Dec 24, 2025
gh-120321: Fix TSan reported races on gi_frame_state #143128
Merged
@kumaraditya303 kumaraditya303 mentioned this pull request Jan 17, 2026
gh-143939: Fix assignment to _PyThreadStateImpl.generator_return_kind #143951
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mpage mpage mpage approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news topic-free-threading

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@colesbury @mpage
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.