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
There are a few thread-safety issues with intern_common:
It can return a string that's not marked as interned because we insert into interned before we mark the string as interned. This can be fixed with some additional locking.
The Py_SET_REFCNT(s, Py_REFCNT(s) - 2) modification is not thread-safe with respect to other reference count modifications in the free threading build
Bug report
When running
./python -m test test_exceptions --parallel-threads=10in a TSAN build:There are a few thread-safety issues with
intern_common:internedbefore we mark the string as interned. This can be fixed with some additional locking.Py_SET_REFCNT(s, Py_REFCNT(s) - 2)modification is not thread-safe with respect to other reference count modifications in the free threading build_Py_SetImmortalis not thread-safe in some circumstances (see_Py_SetImmortalmust be run on allocating thread (no-gil) #113956)The
_Py_SetImmortal()issue is tricky and I think it's unlikely to cause problems in practice, so I think we can defer dealing with that for now.Linked PRs
intern_commonin the free threaded build #130089