Skip to content

data race with extension modules checking for empty weaklist #135607

Open
@kumaraditya303

Description

@kumaraditya303

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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions