Skip to content

Commit d2a0054

Browse files
committed
[windows] avoid overflowing literal STATUS_STACK_OVERFLOW as i32
1 parent df1e6da commit d2a0054

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

rayon-core/tests/stack_overflow_crash.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ fn force_stack_overflow(depth: u32) {
1515
}
1616
}
1717

18+
#[cfg(unix)]
19+
fn overflow_code() -> Option<i32> {
20+
None
21+
}
22+
23+
#[cfg(windows)]
24+
fn overflow_code() -> Option<i32> {
25+
use std::os::windows::process::ExitStatusExt;
26+
use std::process::ExitStatus;
27+
28+
ExitStatus::from_raw(0xc00000fd /*STATUS_STACK_OVERFLOW*/).code()
29+
}
30+
1831
fn main() {
1932
if env::args().len() == 1 {
2033
// first check that the recursivecall actually causes a stack overflow, and does not get optimized away
@@ -24,11 +37,8 @@ fn main() {
2437
.status()
2538
.unwrap();
2639

27-
#[cfg(windows)]
28-
assert_eq!(status.code(), Some(0xc00000fd /*STATUS_STACK_OVERFLOW*/));
29-
30-
#[cfg(unix)]
31-
assert_eq!(status.code(), None);
40+
#[cfg(any(unix, windows))]
41+
assert_eq!(status.code(), overflow_code());
3242

3343
#[cfg(target_os = "linux")]
3444
assert!(

0 commit comments

Comments
 (0)