Skip to content

thread.c: fix fiber_scheduler_closed and event_thread_end_hooked clobbering #14128

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ArtSin
Copy link
Contributor

@ArtSin ArtSin commented Aug 6, 2025

The variables fiber_scheduler_closed and event_thread_end_hooked are modified between setjmp and longjmp calls. Since they are ints and their addresses are not used, they can be allocated on registers and get clobbered. Fix by making them volatile.

This bug can be observed by adding printfs for the variables before the ifs where they are checked, building with Clang, and running bootstraptest/test_ractor.rb:286. The second time, the variables should be equal to 1, but they are reset to 0.

…clobbering

The variables `fiber_scheduler_closed` and `event_thread_end_hooked` are
modified between `setjmp` and `longjmp` calls. Since they are `int`s and their
addresses are not used, they can be allocated on registers and get clobbered.
Fix by making them `volatile`.

This bug can be observed by adding `printf`s for the variables before the `if`s
where they are checked, building with Clang, and running
`bootstraptest/test_ractor.rb:286`. The second time, the variables should be
equal to 1, but they are reset to 0.
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.

1 participant