]>
git.proxmox.com Git - rustc.git/blob - src/vendor/rayon/tests/run-pass/stack_overflow_crash.rs
5 use std
::process
::{self, Command}
;
8 #[cfg(target_os = "linux")]
9 use std
::os
::unix
::process
::ExitStatusExt
;
13 fn force_stack_overflow(depth
: u32) {
14 let buffer
= [0u8; 1024*1024];
16 force_stack_overflow(depth
- 1);
21 if env
::args().len() == 1 {
22 // first check that the recursivecall actually causes a stack overflow, and does not get optimized away
24 let status
= Command
::new(env
::current_exe().unwrap())
30 assert_eq
!(status
.code(), Some(0xc00000fd /*STATUS_STACK_OVERFLOW*/));
33 assert_eq
!(status
.code(), None
);
35 #[cfg(target_os = "linux")]
36 assert
!(status
.signal() == Some(11 /*SIGABRT*/) ||
37 status
.signal() == Some(6 /*SIGSEGV*/));
41 // now run with a larger stack and verify correct operation
43 let status
= Command
::new(env
::current_exe().unwrap())
47 assert_eq
!(status
.code(), Some(0));
48 #[cfg(target_os = "linux")]
49 assert_eq
!(status
.signal(), None
);
52 let stack_size_in_mb
: usize = env
::args().nth(1).unwrap().parse().unwrap();
53 let pool
= ThreadPoolBuilder
::new().stack_size(stack_size_in_mb
* 1024 * 1024).build().unwrap();
54 let index
= pool
.install(|| {
55 force_stack_overflow(32);