]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (GH-119527) (#119746)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 29 May 2024 19:47:47 +0000 (21:47 +0200)
committerGitHub <noreply@github.com>
Wed, 29 May 2024 19:47:47 +0000 (19:47 +0000)
commitdcfbd3be9f1e0ba7aa32214e8f5f7f2ea4375a28
treec18442ddd58bc4e2b883e7a52343be4abb55f47c
parent40a024c9835cddd85f14bab4b1e8f6545a621208
[3.13] gh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (GH-119527) (#119746)

The deadlock only affected the free-threaded build and only occurred
when the GIL was enabled at runtime. The `Py_DECREF(old_name)` call
might temporarily release the GIL while holding the type seqlock.
Another thread may spin trying to acquire the seqlock while holding the
GIL.

The deadlock occurred roughly 1 in ~1,000 runs of `pool_in_threads.py`
from `test_multiprocessing_pool_circular_import`.
(cherry picked from commit c22323cd1c200ca1b22c47af95f67c4b2d661fe7)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Misc/NEWS.d/next/Core and Builtins/2024-05-24-21-04-00.gh-issue-119525.zLFLf1.rst [new file with mode: 0644]
Objects/typeobject.c