You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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():
I think it's worth swapping the order of the calls so that we call current_fast_clear before tstate_delete_common. This would also make the order of operations in PyThreadState_DeleteCurrent() more similar to the order used when calling PyThreadState_Delete().
…16517)
This moves `current_fast_clear()` up so that the current thread state is
`NULL` while running `tstate_delete_common()`.
This doesn't fix any bugs, but it means that we are more consistent that
`_PyThreadState_GET() != NULL` means that the thread is "attached".
…() (python#116517)
This moves `current_fast_clear()` up so that the current thread state is
`NULL` while running `tstate_delete_common()`.
This doesn't fix any bugs, but it means that we are more consistent that
`_PyThreadState_GET() != NULL` means that the thread is "attached".
diegorusso
pushed a commit
to diegorusso/cpython
that referenced
this issue
Apr 17, 2024
…() (python#116517)
This moves `current_fast_clear()` up so that the current thread state is
`NULL` while running `tstate_delete_common()`.
This doesn't fix any bugs, but it means that we are more consistent that
`_PyThreadState_GET() != NULL` means that the thread is "attached".
Feature or enhancement
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():cpython/Python/pystate.c
Lines 1689 to 1691 in 601f3a7
I think it's worth swapping the order of the calls so that we call
current_fast_clear
beforetstate_delete_common
. This would also make the order of operations inPyThreadState_DeleteCurrent()
more similar to the order used when callingPyThreadState_Delete()
.See also: #116483
cc @ericsnowcurrently
Linked PRs
The text was updated successfully, but these errors were encountered: