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
I talked about this with @encukou. Assuming the crypt_r call itself is thread safe1, the only potentially problematic part of the code is Py_TYPE(args[1])->tp_name:
PyExc_TypeError, "crypt argument 1 (word) must be string, not %s",
Py_TYPE(args[0])->tp_name
);
an argument is passed of type X
we call Py_TYPE on it, and get X which does not increment the refcount
the type of the argument is changed by another thread (e.g. by assigning to __class__)
all other instances of this type are gone, garbage collected, the type is deallocated
we call ->tp_name on garbage
This is technically almost impossible to happen but it might :D
A solution is to use the %T format here instead, which likely has the same problem, but the implementation is in Python and is no longer "our problem". %T was added in Python 3.13.
Footnotes
Where the r stands for re-entrant, so we assume it is. ↩