-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-108724: Fix _PySemaphore_Wait call during thread deletion #116483
Conversation
In general, when `_PyThreadState_GET()` is non-NULL then the current thread is "attached", but there is a small window during `PyThreadState_DeleteCurrent()` where that's not true: tstate_delete_common is called when the thread is detached, but before current_fast_clear(). This updates _PySemaphore_Wait() to handle that case.
e4aa866
to
6a6ca9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I have one very minor comment about the applicability of the PyEval_ReleaseThread()
call. Feel free to address it (or not) how you think makes sense.
As to the motivation for this PR, should we aim for eliminating the small window you described in PR description? It vaguely feels like something is our of whack with that.
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Yeah, I'll put up another PR that does that as well. |
…ython#116483) In general, when `_PyThreadState_GET()` is non-NULL then the current thread is "attached", but there is a small window during `PyThreadState_DeleteCurrent()` where that's not true: tstate_delete_common() is called when the thread is detached, but before current_fast_clear(). Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
…ython#116483) In general, when `_PyThreadState_GET()` is non-NULL then the current thread is "attached", but there is a small window during `PyThreadState_DeleteCurrent()` where that's not true: tstate_delete_common() is called when the thread is detached, but before current_fast_clear(). Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
In general, when
_PyThreadState_GET()
is non-NULL then the current thread is "attached", but there is a small window duringPyThreadState_DeleteCurrent()
where that's not true:tstate_delete_common()
is called when the thread is detached, but before current_fast_clear().This updates
_PySemaphore_Wait()
to handle that case.