Skip to content

Commit 0bbb25d

Browse files
Rollup merge of rust-lang#130132 - sunshowers:illumos-sigsegv, r=Noratrieb
[illumos] enable SIGSEGV handler to detect stack overflows Use the same code as Solaris. I couldn't find any tests regarding this, but I did test a stage0 build against my stack-exhaust-test binary [1]. Before: ``` running with use_stacker = No, new_thread = false, make_large_local = false zsh: segmentation fault (core dumped) cargo run ``` After: ``` running with use_stacker = No, new_thread = false, make_large_local = false thread 'main' has overflowed its stack fatal runtime error: stack overflow zsh: IOT instruction (core dumped) cargo +stage0 run ``` Fixes rust-lang#128568. [1] https://github.com/sunshowers/stack-exhaust-test/
2 parents ec7fd8a + af9a77d commit 0bbb25d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

std/src/sys/pal/unix/stack_overflow.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ impl Drop for Handler {
3232
target_os = "macos",
3333
target_os = "netbsd",
3434
target_os = "openbsd",
35-
target_os = "solaris"
35+
target_os = "solaris",
36+
target_os = "illumos",
3637
))]
3738
mod imp {
3839
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
@@ -280,7 +281,7 @@ mod imp {
280281
libc::SIGSTKSZ
281282
}
282283

283-
#[cfg(target_os = "solaris")]
284+
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
284285
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
285286
let mut current_stack: libc::stack_t = crate::mem::zeroed();
286287
assert_eq!(libc::stack_getbounds(&mut current_stack), 0);
@@ -486,7 +487,12 @@ mod imp {
486487
Some(guardaddr..guardaddr + page_size)
487488
}
488489

489-
#[cfg(any(target_os = "macos", target_os = "openbsd", target_os = "solaris"))]
490+
#[cfg(any(
491+
target_os = "macos",
492+
target_os = "openbsd",
493+
target_os = "solaris",
494+
target_os = "illumos",
495+
))]
490496
// FIXME: I am probably not unsafe.
491497
unsafe fn current_guard() -> Option<Range<usize>> {
492498
let stackptr = get_stack_start()?;
@@ -569,7 +575,8 @@ mod imp {
569575
target_os = "macos",
570576
target_os = "netbsd",
571577
target_os = "openbsd",
572-
target_os = "solaris"
578+
target_os = "solaris",
579+
target_os = "illumos",
573580
)))]
574581
mod imp {
575582
pub unsafe fn init() {}

0 commit comments

Comments
 (0)