

-
On Unix targets, it installs a signal handler for SIGSEGV and checks if the faulting address falls within the range of the stack guards. See https://github.com/rust-lang/rust/blob/411f34b/library/std/s...
The stack guards would normally be setup by the system runtime (e.g. kernel in the case of the main thread stack, libc for thread stacks), not Rust's runtime. Likewise, stack probes that ensure stack operations don't skip guard pages are usually (always?) emitted by the compiler backend (e.g. GCC, LLVM), not Rust's instrumentation, per se.
In this sense Rust isn't doing anything different than any other typical C or C++ binary, except hijacking SIGSEGV as Rust does is normally frowned upon, especially when it's merely for aesthetics--i.e. printing a pretty message. Also, attempting to introspect current thread metadata from a signal handler gives me pause. I'm not familiar enough with Rust to down the underlying code. I presume it's using at some POSIX threads interfaces, but POSIX thread interfaces aren't async-signal-safe, and though SIGSEGV is a synchronous signal, that doesn't mean the Rust runtime isn't technically relying on undefined behavior.
-
CodeRabbit
CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
-