Skip to content

[3.8] bpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780)#18945

Merged
miss-islington merged 1 commit intopython:3.8from
miss-islington:backport-64838ce-3.8
Mar 11, 2020
Merged

[3.8] bpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780)#18945
miss-islington merged 1 commit intopython:3.8from
miss-islington:backport-64838ce-3.8

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented Mar 11, 2020

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 [email protected]
(cherry picked from commit 64838ce)

Co-authored-by: bobince [email protected]

https://bugs.python.org/issue39847

…8780)

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 <[email protected]>
(cherry picked from commit 64838ce)

Co-authored-by: bobince <[email protected]>
Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM, good bot.

@miss-islington
Copy link
Copy Markdown
Contributor Author

@bobince and @vstinner: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 60b1b5a into python:3.8 Mar 11, 2020
@miss-islington miss-islington deleted the backport-64838ce-3.8 branch March 11, 2020 23:57
@miss-islington
Copy link
Copy Markdown
Contributor Author

@bobince and @vstinner: Status check is done, and it's a success ✅ .

1 similar comment
@miss-islington
Copy link
Copy Markdown
Contributor Author

@bobince and @vstinner: Status check is done, and it's a success ✅ .

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