Skip to content

[BUG] _PyObject_GetDictPtr used by cython is not safe in free-threading #7200

@kumaraditya303

Description

@kumaraditya303

Describe the bug

Cython uses _PyObject_GetDictPtr in __Pyx_PyObject_GetMethod and reads the dict pointer directly. In free-threading the dict pointer is stored atomically as such it will lead to data races when dict is changed concurrently on the object.

dictptr = _PyObject_GetDictPtr(obj);

Code to reproduce the behaviour:

No response

Expected behaviour

No data races

OS

Linux

Python version

3.14

Cython version

main

Additional context

See _PyObject_SetManagedDict in CPython for the use of atomic for setting the dict.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions