-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Disregard si_addr for fatal signals sent from other processes #10201
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
Conversation
signal.c
Outdated
@@ -872,9 +872,9 @@ check_stack_overflow(int sig, const void *addr) | |||
# else | |||
# define FAULT_ADDRESS info->si_addr | |||
# ifdef USE_UCONTEXT_REG | |||
# define CHECK_STACK_OVERFLOW() check_stack_overflow(sig, (uintptr_t)FAULT_ADDRESS, ctx) | |||
# define CHECK_STACK_OVERFLOW() if (!info->si_pid) check_stack_overflow(sig, (uintptr_t)FAULT_ADDRESS, ctx) |
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.
Could you keep it an expression?
# define CHECK_STACK_OVERFLOW() if (!info->si_pid) check_stack_overflow(sig, (uintptr_t)FAULT_ADDRESS, ctx) | |
# define CHECK_STACK_OVERFLOW() (info->si_pid ? (void)0 : check_stack_overflow(sig, (uintptr_t)FAULT_ADDRESS, ctx)) |
Previously, when another process sends a fatal signals such as SIGBUS to Ruby, we could mis-interpret it as a stack overflow Ruby itself generated. When the si_pid field is set on the signal, we shouldn't check the si_addr field to check for stack overflow. > Signals sent with kill(2) and sigqueue(3) fill in si_pid and si_uid. Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
1c6f219
to
10f9d7e
Compare
Launchable Report❌ Test session #2707587 failed Passed test sessions✅ Test session #2707576 passed Build: refs_pull_10201_merge_10f9d7e686324388bf3fdbc25b0f10ce8355f281 |
I guess you are using macOS or Linux because you mentioned SIGBUS. However, on Linux, In short, the stack overflow check does not work on Linux since this PR. |
On Linux, `siginfo_t` uses a union for each `si_code`, and the field corresponding to `si_pid` does not belong to the `_sigfault` field for SIGSEGV. It actually overlaps the `si_addr` field, which is usually non-zero on stack overflow. ruby#10201 (comment)
Ah, thank you. This was for Linux (we send SIGBUS with
|
Previously, when another process sends a fatal signals such as SIGBUS to Ruby, we could mis-interpret it as a stack overflow Ruby itself generated. When the si_pid field is set on the signal, we shouldn't check the si_addr field to check for stack overflow.