Skip to content

[3.7] bpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780)#18959

Merged
miss-islington merged 1 commit into
python:3.7from
bobince:backport-64838ce-3.7
Mar 12, 2020
Merged

[3.7] bpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780)#18959
miss-islington merged 1 commit into
python:3.7from
bobince:backport-64838ce-3.7

Conversation

@bobince

@bobince bobince commented Mar 12, 2020

Copy link
Copy Markdown
Contributor

The 32-bit (49-day) TickCount relied on in EnterNonRecursiveMutex can overflow
in the gap between the 'target' time and the 'now' time WaitForSingleObjectEx
returns, causing the loop to think it needs to wait another 49 days. This is
most likely to happen when the machine is hibernated during
WaitForSingleObjectEx.

This makes acquiring a lock/event/etc from the _thread or threading module
appear to never timeout.

Replace with GetTickCount64 - this is OK now Python no longer supports XP which
lacks it, and is in use for time.monotonic().

Co-authored-by: And Clover and.clover@bromium.com
(cherry picked from commit 64838ce)

Co-authored-by: bobince and+github@doxdesk.com

https://bugs.python.org/issue39847

Automerge-Triggered-By: @vstinner

…onGH-18780)

The 32-bit (49-day) TickCount relied on in EnterNonRecursiveMutex can overflow
in the gap between the 'target' time and the 'now' time WaitForSingleObjectEx
returns, causing the loop to think it needs to wait another 49 days. This is
most likely to happen when the machine is hibernated during
WaitForSingleObjectEx.

This makes acquiring a lock/event/etc from the _thread or threading module
appear to never timeout.

Replace with GetTickCount64 - this is OK now Python no longer supports XP which
lacks it, and is in use for time.monotonic().

Co-authored-by: And Clover <and.clover@bromium.com>
(cherry picked from commit 64838ce)

Co-authored-by: bobince <and+github@doxdesk.com>

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

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.

5 participants