-
-
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
Rust custom signal handler ignores first SIGSEGV #6759
Comments
I have a working fix. I just need a bit of time and I'll send a PR. |
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 21, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 21, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 21, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 21, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 21, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 25, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 25, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 25, 2024
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 ```
Ecordonnier
added a commit
to Ecordonnier/coreutils
that referenced
this issue
Oct 25, 2024
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 ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rust adds a custom UNIX signal handler to Rust processes ( see https://github.com/rust-lang/rust/blob/8ac1525e091d3db28e67adcbbd6db1e1deaa37fb/src/libstd/sys/unix/stack_overflow.rs#L71-L92 ).
In the case of SIGSEGV (signal segmentation violation), the behavior of this custom signal handler is to ignore the first signal, and then restore the default signal handler. The default signal handler makes the process dump core, thus this means that rust processes need to receive two SIGSEGV in order to dump core, unlike standard C processes which dump core after one SIGSEGV.
This causes uutils-coreutils to behave differently than GNU coreutils:
Behavior of uutils-coreutils (process dumps core after two SIGSEGV signals):
Behavior of GNU coreutils (process dumps core after one SIGSEGV signal):
(In case you're not familiar with coredumps, note that one easy way to check if a process has dumped core is to use coredumpctl list, available e.g. on Ubuntu with the apt package systemd-coredump. coredumps are also logged to the systemd journal and thus visible with journalctl).
The text was updated successfully, but these errors were encountered: