Skip to content
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

[3.13] gh-127421: Fix race in test_start_new_thread_failed (GH-127549) #127574

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Dec 3, 2024

Fix race in test_start_new_thread_failed

When we succeed in starting a new thread, for example if setrlimit
was ineffective, we must wait for the newly spawned thread to exit.
Otherwise, we run the risk that the newly spawned thread will race
with runtime finalization and access memory that has already been
clobbered/freed.

_thread.start_new_thread() only spawns daemon threads, which the runtime
does not wait for at shutdown, and does not return a handle. Use
_thread.start_joinable_thread() and join the resulting handle when
the thread is started successfully.
(cherry picked from commit 13b68e1)

Co-authored-by: mpage mpage@meta.com

…27549)

Fix race in test_start_new_thread_failed

When we succeed in starting a new thread, for example if setrlimit
was ineffective, we must wait for the newly spawned thread to exit.
Otherwise, we run the risk that the newly spawned thread will race
with runtime finalization and access memory that has already been
clobbered/freed.

`_thread.start_new_thread()` only spawns daemon threads, which the runtime
does not wait for at shutdown, and does not return a handle. Use
`_thread.start_joinable_thread()` and join the resulting handle when
the thread is started successfully.
(cherry picked from commit 13b68e1)

Co-authored-by: mpage <mpage@meta.com>
@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Dec 3, 2024
@mpage mpage requested a review from colesbury December 3, 2024 18:24
@mpage mpage merged commit 0b266aa into python:3.13 Dec 3, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants