Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-108724: Fix _PySemaphore_Wait call during thread deletion#116483
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In general, when `_PyThreadState_GET()` is non-NULL then the currentthread 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 beforecurrent_fast_clear().This updates _PySemaphore_Wait() to handle that case.
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 thePyEval_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.
Uh oh!
There was an error while loading.Please reload this page.
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 currentthread 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 beforecurrent_fast_clear().Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
…ython#116483)In general, when `_PyThreadState_GET()` is non-NULL then the currentthread 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 beforecurrent_fast_clear().Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
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.