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

Fix Thread#join when scheduler is used (2nd attempt). #4689

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

ioquatix
Copy link
Member

We ran into a second race condition due to the assignment of th->value before running the scheduler. This ensures that th->value is not assigned until AFTER the thread's observable behaviour is fully completed.

@ioquatix ioquatix force-pushed the scheduler-thread-join-fix branch 3 times, most recently from 335f721 to f7f73cd Compare July 30, 2021 05:15
If the thread termination invokes user code after `th->status` becomes
`THREAD_KILLED`, and the user unblock function causes that `th->status` to
become something else (e.g. `THREAD_RUNNING`), threads waiting in
`thread_join_sleep` will hang forever. We move the unblock function call
to before the thread status is updated, and allow threads to join as soon
as `th->value` becomes defined.

This reverts commit 6505c77.
@ioquatix ioquatix merged commit 2d4f29e into ruby:master Aug 3, 2021
@ioquatix ioquatix deleted the scheduler-thread-join-fix branch August 3, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant