-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deadlock in pool_in_threads.py
(test_multiprocessing_pool_circular_import
) in free-threaded build
#119369
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
topic-free-threading
type-bug
An unexpected behavior, bug, or error
Comments
colesbury
added
type-bug
An unexpected behavior, bug, or error
topic-free-threading
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
labels
May 21, 2024
Two possible strategies:
|
colesbury
added a commit
to colesbury/cpython
that referenced
this issue
May 24, 2024
Release the GIL before calling `_Py_qsbr_unregister`. The deadlock could occur when the GIL was enabled at runtime. The `_Py_qsbr_unregister` call might block while holding the GIL because the thread state was not active, but the GIL was still held.
colesbury
added a commit
that referenced
this issue
May 31, 2024
…19528) Release the GIL before calling `_Py_qsbr_unregister`. The deadlock could occur when the GIL was enabled at runtime. The `_Py_qsbr_unregister` call might block while holding the GIL because the thread state was not active, but the GIL was still held.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
May 31, 2024
…ld (pythonGH-119528) Release the GIL before calling `_Py_qsbr_unregister`. The deadlock could occur when the GIL was enabled at runtime. The `_Py_qsbr_unregister` call might block while holding the GIL because the thread state was not active, but the GIL was still held. (cherry picked from commit 078b8c8) Co-authored-by: Sam Gross <[email protected]>
colesbury
added a commit
that referenced
this issue
May 31, 2024
…ild (GH-119528) (#119868) Release the GIL before calling `_Py_qsbr_unregister`. The deadlock could occur when the GIL was enabled at runtime. The `_Py_qsbr_unregister` call might block while holding the GIL because the thread state was not active, but the GIL was still held. (cherry picked from commit 078b8c8) Co-authored-by: Sam Gross <[email protected]>
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
…ld (python#119528) Release the GIL before calling `_Py_qsbr_unregister`. The deadlock could occur when the GIL was enabled at runtime. The `_Py_qsbr_unregister` call might block while holding the GIL because the thread state was not active, but the GIL was still held.
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
…ld (python#119528) Release the GIL before calling `_Py_qsbr_unregister`. The deadlock could occur when the GIL was enabled at runtime. The `_Py_qsbr_unregister` call might block while holding the GIL because the thread state was not active, but the GIL was still held.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
topic-free-threading
type-bug
An unexpected behavior, bug, or error
Bug report
Running
pool_in_threads.py
in a loop will occasionally lead to deadlock even with #118745 applied.Here's a summary of the state I observed:
Thread 28
Thread 28 holds the GIL and is blocked on the QSBR shared mutex:
It's blocked trying to lock the QSBR shared mutex:
cpython/Python/qsbr.c
Line 194 in 9fa206a
Normally, this would release the GIL while blocking, but we clear the thread state before calling
tstate_delete_common
:cpython/Python/pystate.c
Lines 1844 to 1845 in 9fa206a
We only detach (and release the GIL) if we both have a thread state and it's currently attached:
cpython/Python/parking_lot.c
Lines 204 to 207 in 9fa206a
Note that the PyThreadState in this case is actually attached, just not visible from
_PyThreadState_GET()
.Thread 4
Thread 4 holds the shared mutex and is blocked trying to acquire the GIL:
Linked PRs
The text was updated successfully, but these errors were encountered: