FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.12] gh-108987: Fix _thread.start_new_thread() race condition (#109135) by vstinner · Pull Request #110342 · python/cpython · GitHub

Repository navigation

[3.12] gh-108987: Fix _thread.start_new_thread() race condition (#109135) - #110342

Merged
vstinner merged 2 commits into
python:3.12from
vstinner:start_new_thread12
Oct 4, 2023
Merged

vstinner merged 2 commits into
python:3.12from
vstinner:start_new_thread12

Conversation

vstinner commented Oct 4, 2023 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Fix _thread.start_new_thread() race condition. If a thread is created during Python finalization, the newly spawned thread now exits immediately instead of trying to access freed memory and lead to a crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread must exit. The problem was that tstate was dereferenced earlier in _PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to _PyThreadState_Bind().

(cherry picked from commit 517cd82)

…n#109135)

Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().

(cherry picked from commit 517cd82)
…e using raw memory allocator (python#109808)

(cherry picked from commit 1b8f236)
vstinner enabled auto-merge (squash) October 4, 2023 10:41
vstinner merged commit 4936fa9 into python:3.12 Oct 4, 2023
vstinner deleted the start_new_thread12 branch October 4, 2023 11:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL