Closed
Description
Bug report
Bug description:
The implementation of _thread.lock.release()
manipulates the locked
field in a thread-unsafe way (this may be called by a thread that does not hold the lock) in free-threaded builds:
cpython/Modules/_threadmodule.c
Lines 813 to 825 in 630df37
We're choosing to punt on this for 3.13 since this should only be problematic for contended unlocks. We can revisit this for 3.13 if it turns out to be an issue in practice.
Post 3.13 we would like to change the underlying lock to be a PyMutex
and replace the implementation with something like:
static PyObject *
lock_PyThread_release_lock(lockobject *self, PyObject *Py_UNUSED(ignored))
{
/* Sanity check: the lock must be locked */
if (_PyMutex_TryUnlock(&self->mutex) < 0) {
PyErr_SetString(ThreadError, "release unlocked lock");
return NULL;
}
Py_RETURN_NONE;
}
CPython versions tested on:
3.13
Operating systems tested on:
Linux