]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-120858: PyDict_Next should not lock the dict (GH-120859) (#120964)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 24 Jun 2024 18:41:19 +0000 (20:41 +0200)
committerGitHub <noreply@github.com>
Mon, 24 Jun 2024 18:41:19 +0000 (18:41 +0000)
commit0a77058b7971ba140c1f9db443e536ea5f1d71aa
treeb49acc756824d61cbf0ff353ceab54311b24fe2a
parent6aee5edb84cfa23f430091270a4118e51894c767
[3.13] gh-120858: PyDict_Next should not lock the dict (GH-120859) (#120964)

PyDict_Next no longer locks the dictionary in the free-threaded build. Locking
around individual PyDict_Next calls is not sufficient because the function
returns borrowed references and because it allows concurrent modifications
during the iteraiton loop.

The internal locking also interferes with correct external synchronization
because it may suspend outer critical sections created by the caller.
(cherry picked from commit 375b723d5873f948696c7e85a97f4778d9e00ff0)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Doc/c-api/dict.rst
Doc/howto/free-threading-extensions.rst
Misc/NEWS.d/next/C API/2024-06-21-16-41-21.gh-issue-120858.Z5_-Mn.rst [new file with mode: 0644]
Objects/dictobject.c