You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
data race with extension modules checking for empty weaklist #135607
Extension modules which check for self->weakreflist != NULL in tp_dealloc before calling PyObject_ClearWeakRefs(self) leads to to data race if another thread is concurrently mutating the weaklist.
In free-threading the weaklist is modified atomically as such it can cause data race with the non atomic reads in extension modules. This can be avoided in extension modules by calling PyObject_ClearWeakRefs always and removing checking for weaklist == NULL.
Activity
colesbury commentedon Jun 17, 2025
The explanation is clear. I don't think you need to find a repro for this.
Unconditionally clear weak refs in ctypdescr_dealloc to avoid race in…
gh-135607: remove null checking of weakref list in dealloc of extensi…
pythongh-135607: remove null checking of weakref list in dealloc of e…
pythongh-135607: remove null checking of weakref list in dealloc of e…
[3.14] gh-135607: remove null checking of weakref list in dealloc of …
pythongh-135607: remove null checking of weakref list in dealloc of e…
[3.13] gh-135607: remove null checking of weakref list in dealloc of …
pythongh-135607: remove null checking of weakref list in dealloc of e…
pythongh-135607: remove null checking of weakref list in dealloc of e…
pythongh-135607: remove null checking of weakref list in dealloc of e…
Add support for the free-threaded build (#178)
pythongh-135607: remove null checking of weakref list in dealloc of e…
pythongh-135607: remove null checking of weakref list in dealloc of e…