]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-132641: fix race in `lru_cache` under free-threading (GH-133787) (#133979)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 14 May 2025 07:11:38 +0000 (09:11 +0200)
committerGitHub <noreply@github.com>
Wed, 14 May 2025 07:11:38 +0000 (07:11 +0000)
commit66d6860439c676973ff589b1d4594178a065fff5
tree8a20764c6daf80876c86c12872b008486105fa07
parentb94a63c0f19cae7a10f923adf60277304d6cfdbf
[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 9ad0c7b0f14c5fcda6bfae6692c88abb95502d38)

Co-authored-by: Peter Hawkins <phawkins@google.com>
Include/internal/pycore_dict.h
Lib/test/test_free_threading/test_functools.py [new file with mode: 0644]
Misc/NEWS.d/next/Library/2025-05-09-20-59-24.gh-issue-132641.3qTw44.rst [new file with mode: 0644]
Modules/_functoolsmodule.c
Objects/dictobject.c