◐ Shell
clean mode source ↗

gh-120321: Fix TSan reported races on gi_frame_state by colesbury · Pull Request #143128 · python/cpython

@colesbury

This is the same thing as #142995, but I missed a few cases. Again, I think these are false positives in the sense that TSan treats failed compare-exchanges as if they are modifications, when they don't perform any modification on failure.

@kumaraditya303

In _PyGen_Finalize there are a few non-atomic reads of gi_frame_state, does that need fixing as well?

@colesbury

No, _PyGen_Finalize is called when there are no other references to the generator (except cycles), so there's no concurrent compare-exchanges on gi_frame_state.

@kumaraditya303

No, _PyGen_Finalize is called when there are no other references to the generator (except cycles), so there's no concurrent compare-exchanges on gi_frame_state.

It is possible that _PyGen_Finalize gets called from frame.clear though so IIUC it is not guaranteed to be called only when there are no other references to generator.

_PyGen_Finalize((PyObject *)gen);

@colesbury

kumaraditya303