Skip to content

Commit 2e9fe78

Browse files
committed
Add note about Rust's segfault handler
1 parent e63adc7 commit 2e9fe78

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/stdext/src/traps.rs

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
//
1212
// This uses `signal()` instead of `sigaction()` for Windows support
1313
// (SIGSEGV is one of the rare supported signals)
14+
//
15+
// Note that Rust also has a SIGSEGV handler to catch stack overflows. In
16+
// this case it displays an informative message and aborts the program (no
17+
// segfaults in Rust!). Ideally we'd save the Rust handler and notify
18+
// it. However the only safe way to notify an old handler on Unixes is to
19+
// use `sigaction()` so that we get the information needed to determine the
20+
// type of handler (old or new school). So we'd need to make a different
21+
// implementation for Windows (which only supports old style) and for Unix,
22+
// and this doesn't seem worth it.
1423
pub fn register_trap_handlers() {
1524
unsafe {
1625
libc::signal(libc::SIGBUS, backtrace_handler as libc::sighandler_t);

0 commit comments

Comments
 (0)