gh-132641: fix race in lru_cache under free-threading (#133787)

Fix race in `lru_cache` by acquiring critical section on the cache object itself and call the lock held variant of dict functions to modify the underlying dict.
This commit is contained in:
Peter Hawkins 2025-05-13 13:38:57 -04:00 committed by GitHub
parent 35f47d0589
commit 9ad0c7b0f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 94 additions and 5 deletions

View file

@ -2915,6 +2915,11 @@ clear_lock_held(PyObject *op)
ASSERT_CONSISTENT(mp);
}
void
_PyDict_Clear_LockHeld(PyObject *op) {
clear_lock_held(op);
}
void
PyDict_Clear(PyObject *op)
{