FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-108724: Fix _PySemaphore_Wait call during thread deletion by colesbury · Pull Request #116483 · python/cpython · GitHub

/ cpython Public

gh-108724: Fix _PySemaphore_Wait call during thread deletion - #116483

Merged
colesbury merged 3 commits into
python:mainfrom
colesbury:gh-108724-sema-wait
Mar 8, 2024
Merged

gh-108724: Fix _PySemaphore_Wait call during thread deletion#116483
colesbury merged 3 commits into
python:mainfrom
colesbury:gh-108724-sema-wait

Conversation

colesbury commented Mar 7, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

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.

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.
colesbury force-pushed the gh-108724-sema-wait branch from e4aa866 to 6a6ca9e Compare March 7, 2024 23:29
colesbury changed the title gh-116480: Fix _PySemaphore_Wait call during thread deletion gh-108724: Fix _PySemaphore_Wait call during thread deletion Mar 7, 2024

ericsnowcurrently left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread Python/parking_lot.c Outdated
colesbury and others added 2 commits March 8, 2024 14:52
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>

Copy link
Copy Markdown
Contributor Author

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.

Yeah, I'll put up another PR that does that as well.

colesbury merged commit 3cdfdc0 into python:main Mar 8, 2024
colesbury deleted the gh-108724-sema-wait branch March 8, 2024 20:26
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
…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>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL