Skip to content

Commit f9e8d05

Browse files
committed
Use common si_addr() accessor
Now that all of the UNIX-ish platforms in libc implement this function to extract the si_addr from a siginfo_t, it can be used to simplify such data collection during stack overflow handling.
1 parent e69e652 commit f9e8d05

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

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

+1-17
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@ mod imp {
5454
use crate::sys::unix::os::page_size;
5555
use crate::sys_common::thread_info;
5656

57-
#[cfg(any(target_os = "linux", target_os = "android"))]
58-
unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize {
59-
#[repr(C)]
60-
struct siginfo_t {
61-
a: [libc::c_int; 3], // si_signo, si_errno, si_code
62-
si_addr: *mut libc::c_void,
63-
}
64-
65-
(*(info as *const siginfo_t)).si_addr as usize
66-
}
67-
68-
#[cfg(not(any(target_os = "linux", target_os = "android")))]
69-
unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize {
70-
(*info).si_addr as usize
71-
}
72-
7357
// Signal handler for the SIGSEGV and SIGBUS handlers. We've got guard pages
7458
// (unmapped pages) at the end of every thread's stack, so if a thread ends
7559
// up running into the guard page it'll trigger this handler. We want to
@@ -97,7 +81,7 @@ mod imp {
9781
_data: *mut libc::c_void,
9882
) {
9983
let guard = thread_info::stack_guard().unwrap_or(0..0);
100-
let addr = siginfo_si_addr(info);
84+
let addr = (*info).si_addr() as usize;
10185

10286
// If the faulting address is within the guard page, then we print a
10387
// message saying so and abort.

0 commit comments

Comments
 (0)