Skip to content
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

[illumos] enable SIGSEGV handler to detect stack overflows #130132

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions library/std/src/sys/pal/unix/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ impl Drop for Handler {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris"
target_os = "solaris",
target_os = "illumos",
))]
mod imp {
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
Expand Down Expand Up @@ -280,7 +281,7 @@ mod imp {
libc::SIGSTKSZ
}

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

#[cfg(any(target_os = "macos", target_os = "openbsd", target_os = "solaris"))]
#[cfg(any(
target_os = "macos",
target_os = "openbsd",
target_os = "solaris",
target_os = "illumos",
))]
// FIXME: I am probably not unsafe.
unsafe fn current_guard() -> Option<Range<usize>> {
let stackptr = get_stack_start()?;
Expand Down Expand Up @@ -569,7 +575,8 @@ mod imp {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris"
target_os = "solaris",
target_os = "illumos",
)))]
mod imp {
pub unsafe fn init() {}
Expand Down
Loading