-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix race condition in signal handler query #13712
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 race condition in signal handler query #13712
Conversation
Thanks for taking a look at this! It looks like Windows stuff is failing because there's no static initializer for Window's version of This mutex also needs to be reinitialized after a call to |
@luke-gruber Thanks for the feedback! I will work on making these changes and update the PR. |
1a0bebb
to
3870590
Compare
@luke-gruber I've made the changes you've recommend:
Please let me know if you have any additional feedback. |
signal.c
Outdated
@@ -1561,3 +1566,13 @@ Init_signal(void) | |||
|
|||
rb_enable_interrupt(); | |||
} | |||
|
|||
#if defined(HAVE_WORKING_FORK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition doesn’t look matching the above.
And the function is always needed, so the condition can be in the function body.
6d2387c
to
0fa364c
Compare
I've made the allocation and initialization of Please let me know if I've gotten anything wrong and if you'd like me to make any other changes (e.g. squashing these changes into a single commit). Thanks so much for reviewing this code! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, do you know any platform that is still alive, neither POSIX nor Windows?
I guess some bespoke real-time OSes, stuff within the government (e.g. systems that control rocket ships), and very old mainframes that are still technically "alive", for some definition of that word, but just about everything else is POSIX or Windows. |
Ah, sorry, I meant any of the platforms supported by ruby. |
Introduced a static mutex when checking non-POSIX signal handlers, making the operation thread-safe and preventing races around the signal retrieval and restoration. Fixes TODO added by @luke-gruber in 1d4822a#diff-47e173231fbc1ddb6c555f7116c157cb32ab63d04e85047b55ff378e71fb965eR679.