gh-115103: Fix unregistering of QSBR state by colesbury · Pull Request #116480 · python/cpython

@colesbury

If a thread blocks while waiting on the `shared->mutex` lock, the array
of QSBR states may be reallocated. The `tstate->qsbr` values before the
lock is acquired may not be the same as the value after the lock is acquired.

colesbury added a commit to colesbury/cpython that referenced this pull request

Mar 7, 2024
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.

corona10

adorilson pushed a commit to adorilson/cpython that referenced this pull request

Mar 25, 2024
If a thread blocks while waiting on the `shared->mutex` lock, the array
of QSBR states may be reallocated. The `tstate->qsbr` values before the
lock is acquired may not be the same as the value after the lock is acquired.

diegorusso pushed a commit to diegorusso/cpython that referenced this pull request

Apr 17, 2024
If a thread blocks while waiting on the `shared->mutex` lock, the array
of QSBR states may be reallocated. The `tstate->qsbr` values before the
lock is acquired may not be the same as the value after the lock is acquired.