aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorPeter Hawkins <phawkins@google.com>2025-05-13 13:38:57 -0400
committerGitHub <noreply@github.com>2025-05-13 17:38:57 +0000
commit9ad0c7b0f14c5fcda6bfae6692c88abb95502d38 (patch)
tree8d818a816699d0363098e527fd6f3bfad7cdccc4 /Objects/dictobject.c
parent35f47d05893e012e9f2b145b934c1d8c61d2bb7d (diff)
downloadcpython-9ad0c7b0f14c5fcda6bfae6692c88abb95502d38.tar.gz
cpython-9ad0c7b0f14c5fcda6bfae6692c88abb95502d38.zip
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.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index ce27e47dabf..fd8ccf56324 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2916,6 +2916,11 @@ clear_lock_held(PyObject *op)
}
void
+_PyDict_Clear_LockHeld(PyObject *op) {
+ clear_lock_held(op);
+}
+
+void
PyDict_Clear(PyObject *op)
{
Py_BEGIN_CRITICAL_SECTION(op);