-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
PyMutex
failure in parking_lot.c
on Windows during interpreter shutdown
#135099
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
PyMutex
failure in parking_lot.c
on Windows during interpreter shutdown
On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in `_PySignal_Fini` and threads may still be running and using mutexes during interpreter shtudown. Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like we do in other places in the CPython codebase.
Since #134747 ("Change PyThread_allocate_lock() implementation to PyMutex") was merged, Windows tests got really flaky, with several tests failing in each buildbot run with the same error:
For example, here: https://buildbot.python.org/#/builders/146/builds/11597/steps/5/logs/stdio Currently at the release status page, on several Windows buildbots you can see a point where they "switched" from mostly-green to consistent "warnings" result; on the few I explored the first "yellow" build was for #134747. Do you think that's related? |
Yes, I think it's related |
On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in `_PySignal_Fini` and threads may still be running and using mutexes during interpreter shtudown. Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like we do in other places in the CPython codebase.
…ythonGH-135100) On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in `_PySignal_Fini` and threads may still be running and using mutexes during interpreter shtudown. Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like we do in other places in the CPython codebase. (cherry picked from commit cc581f3) Co-authored-by: Sam Gross <[email protected]>
…H-135100) (GH-135116) On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in `_PySignal_Fini` and threads may still be running and using mutexes during interpreter shtudown. Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like we do in other places in the CPython codebase. (cherry picked from commit cc581f3) Co-authored-by: Sam Gross <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
4294967295
is the-1
return 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) #135116The text was updated successfully, but these errors were encountered: