-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
uucore: disable default signal-handlers added by Rust #6806
Conversation
e0b304b
to
96d70d7
Compare
src/uucore_procs/src/lib.rs
Outdated
@@ -24,6 +24,9 @@ pub fn main(_args: TokenStream, stream: TokenStream) -> TokenStream { | |||
|
|||
let new = quote!( | |||
pub fn uumain(args: impl uucore::Args) -> i32 { | |||
#[cfg(unix)] | |||
uucore::signals::disable_rust_signal_handlers().expect("Disabling rust signal handlers failed"); |
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.
please a comment explaining the why
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.
I added a comment as requested, however it is redundant with the comment above the function definition.
// Disables the custom signal handlers installed by Rust for stack-overflow handling. With those custom signal handlers processes ignore the first SIGBUS and SIGSEGV signal they receive. | ||
// See https://github.com/rust-lang/rust/blob/8ac1525e091d3db28e67adcbbd6db1e1deaa37fb/src/libstd/sys/unix/stack_overflow.rs#L71-L92 for details. | ||
#[cfg(unix)] | ||
pub fn disable_rust_signal_handlers() -> Result<(), Errno> { |
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 please add a test for this?
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.
I added a test for the sleep utility, which relies on this function working as intended. I verified that the test fails if I revert my commit adding this function.
My intent was to not change more code than necessary, however I think kill() and kill_with_custom_signal() could be a single function. Same thing for try_kill() and try_kill_with_custom_signal.
Please also note that I'm a complete beginner in Rust.
c16a512
to
64bc854
Compare
GNU testsuite comparison:
|
Edit: as far as I understand, I can either enable The drawback if I move disable_rust_signal_handlers to lib.rs is that I'll need to add the nix crate as dependency in all utilities:
Which option do you prefer? |
64bc854
to
90a1997
Compare
I fixed the nix dependency issue by moving disable_rust_signal_handlers from uucore_procs/src/lib.rs to src/uucore/src/lib/lib.rs ( as explained in https://users.rust-lang.org/t/proc-macros-using-third-party-crate/42465/3 ). |
8b2a388
to
e37d426
Compare
Fixes uutils#6759 Test procedure (verifies that a single SIGSEGV stops a program): ``` ecordonnier@lj8k2dq3:~/dev/coreutils$ ./target/release/coreutils sleep 100 & [1] 4175464 ecordonnier@lj8k2dq3:~/dev/coreutils$ kill -11 $(pidof coreutils) ecordonnier@lj8k2dq3:~/dev/coreutils$ [1]+ Segmentation fault (core dumped) ./target/release/coreutils sleep 100 ```
e37d426
to
8ab99d4
Compare
Fixes #6759
Test procedure (verifies that a single SIGSEGV stops a program):