Skip to content

Potential Windows-specific lost event race in the implementation of time.sleep #135407

Open
@zackw

Description

@zackw

Bug description:

In the Windows-specific implementation of time.sleep there appears this code:

cpython/Modules/timemodule.c

Lines 2341 to 2345 in b706ff0

// Check for pending SIGINT signal before resetting the event
if (PyErr_CheckSignals()) {
goto error;
}
ResetEvent(sigint_event);

If a control-C event happens after PyErr_CheckSignals returns, but before ResetEvent is called, I believe that event may be lost.

This is probably a hard race window to hit, and I don't have a Windows development environment, so I have not confirmed that it is possible.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions