mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.14] gh-132641: fix race in lru_cache
under free-threading (GH-133787) (#133979)
gh-132641: fix race in `lru_cache` under free-threading (GH-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.
(cherry picked from commit 9ad0c7b0f1
)
Co-authored-by: Peter Hawkins <phawkins@google.com>
This commit is contained in:
parent
b94a63c0f1
commit
66d6860439
5 changed files with 94 additions and 5 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue