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: GC safety in Thread#start #14558

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ysbaddaden
Copy link
Contributor

Follow up to #14554 where a comment by @yxhuvud made me realize that Thread#start wasn't exactly GC safe, in that a GC collection could happen in parallel to a thread starting and it could free the Thread object before the thread is started or before the thread is properly shutdown.

The patch mostly moves the calls to add/remove the thread object from the linked list, along with some explanations.

Note: only the last commit is relevant, the rest is from #14554.

@ysbaddaden ysbaddaden added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:multithreading labels May 3, 2024
@ysbaddaden ysbaddaden self-assigned this May 3, 2024
@ysbaddaden
Copy link
Contributor Author

ysbaddaden commented May 3, 2024

Interestingly that caused CI to segfault with -Dpreview_mt 🤨

Of course, no stacktrace and I can't reproduce.

ysbaddaden added a commit to ysbaddaden/execution_context that referenced this pull request May 6, 2024
ysbaddaden added a commit to ysbaddaden/execution_context that referenced this pull request May 6, 2024
ysbaddaden added a commit to ysbaddaden/execution_context that referenced this pull request Oct 4, 2024
It seems to be creating parallelism issues with the GC instead of fixing
them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:multithreading
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant