Skip to content

[3.14] gh-135099: Only wait on _PyOS_SigintEvent() in main thread (GH-135100) #135116

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

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jun 4, 2025

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 colesbury@gmail.com

…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 <colesbury@gmail.com>
@colesbury colesbury merged commit b2b9aaa into python:3.14 Jun 4, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants