Skip to content

Commit 2cdbd69

Browse files
committed
disable the stack overflow handler on miri
1 parent 84bb0f0 commit 2cdbd69

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

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

+41-29
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,36 @@ impl Drop for Handler {
2525
}
2626
}
2727

28-
#[cfg(any(
29-
target_os = "linux",
30-
target_os = "freebsd",
31-
target_os = "hurd",
32-
target_os = "macos",
33-
target_os = "netbsd",
34-
target_os = "openbsd",
35-
target_os = "solaris",
36-
target_os = "illumos",
28+
#[cfg(all(
29+
not(miri),
30+
any(
31+
target_os = "linux",
32+
target_os = "freebsd",
33+
target_os = "hurd",
34+
target_os = "macos",
35+
target_os = "netbsd",
36+
target_os = "openbsd",
37+
target_os = "solaris",
38+
target_os = "illumos",
39+
),
3740
))]
3841
mod thread_info;
3942

40-
#[cfg(any(
41-
target_os = "linux",
42-
target_os = "freebsd",
43-
target_os = "hurd",
44-
target_os = "macos",
45-
target_os = "netbsd",
46-
target_os = "openbsd",
47-
target_os = "solaris",
48-
target_os = "illumos",
43+
// miri doesn't model signals nor stack overflows and this code has some
44+
// synchronization properties that we don't want to expose to user code,
45+
// hence we disable it on miri.
46+
#[cfg(all(
47+
not(miri),
48+
any(
49+
target_os = "linux",
50+
target_os = "freebsd",
51+
target_os = "hurd",
52+
target_os = "macos",
53+
target_os = "netbsd",
54+
target_os = "openbsd",
55+
target_os = "solaris",
56+
target_os = "illumos",
57+
)
4958
))]
5059
mod imp {
5160
use libc::{
@@ -606,17 +615,20 @@ mod imp {
606615
// usually have fewer qualms about forwards compatibility, since the runtime
607616
// is shipped with the OS):
608617
// <https://github.com/apple/swift/blob/swift-5.10-RELEASE/stdlib/public/runtime/CrashHandlerMacOS.cpp>
609-
#[cfg(not(any(
610-
target_os = "linux",
611-
target_os = "freebsd",
612-
target_os = "hurd",
613-
target_os = "macos",
614-
target_os = "netbsd",
615-
target_os = "openbsd",
616-
target_os = "solaris",
617-
target_os = "illumos",
618-
target_os = "cygwin",
619-
)))]
618+
#[cfg(any(
619+
miri,
620+
not(any(
621+
target_os = "linux",
622+
target_os = "freebsd",
623+
target_os = "hurd",
624+
target_os = "macos",
625+
target_os = "netbsd",
626+
target_os = "openbsd",
627+
target_os = "solaris",
628+
target_os = "illumos",
629+
target_os = "cygwin",
630+
))
631+
))]
620632
mod imp {
621633
pub unsafe fn init() {}
622634

0 commit comments

Comments
 (0)