Open
Description
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
.
I'll try to find a smaller reproducer for this.