Bug report
Bug description:
Fatal Python error: _PySemaphore_PlatformWait: unexpected error from semaphore: 4294967295 (error: 6)
Python runtime state: finalizing (tstate=0x6aa6c460)
Thread 0x00001360 (most recent call first):
<no Python frame>
Windows fatal exception: code 0x80000003
Current thread 0x00001360 (most recent call first):
<no Python frame>
Current thread's C stack trace (most recent call first):
<cannot get C stack on this system>
4294967295 is the -1 return code from WaitForMultipleObjects. Error code 6 is ERROR_INVALID_HANDLE.
I'm pretty sure that the _PyOS_SigintEvent() handle is getting closed concurrently with the mutex wait.
|
HANDLE sigint_event = _PyOS_SigintEvent(); |
|
HANDLE handles[2] = { sema->platform_sem, sigint_event }; |
|
DWORD count = sigint_event != NULL ? 2 : 1; |
|
wait = WaitForMultipleObjects(count, handles, FALSE, millis); |
|
if (wait == WAIT_OBJECT_0) { |
|
res = Py_PARK_OK; |
|
} |
|
else if (wait == WAIT_OBJECT_0 + 1) { |
|
ResetEvent(sigint_event); |
|
res = Py_PARK_INTR; |
|
} |
|
else if (wait == WAIT_TIMEOUT) { |
|
res = Py_PARK_TIMEOUT; |
|
} |
|
else { |
|
_Py_FatalErrorFormat(__func__, |
|
"unexpected error from semaphore: %u (error: %u)", |
|
wait, GetLastError()); |
|
} |
Seen in https://github.com/python/cpython/actions/runs/15423887404/job/43405853684 at the end of running test_decorators.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
Bug report
Bug description:
4294967295is the-1return code fromWaitForMultipleObjects. Error code 6 isERROR_INVALID_HANDLE.I'm pretty sure that the
_PyOS_SigintEvent()handle is getting closed concurrently with the mutex wait.cpython/Python/parking_lot.c
Lines 118 to 136 in 1ffe913
Seen in https://github.com/python/cpython/actions/runs/15423887404/job/43405853684 at the end of running
test_decorators.CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
_PyOS_SigintEvent()in main thread #135100_PyOS_SigintEvent()in main thread (GH-135100) #135116