3 #![allow(unused_must_use)]
4 #![allow(unconditional_recursion)]
5 // ignore-android: FIXME (#20004)
6 // ignore-emscripten no processes
7 // ignore-sgx no processes
9 #![feature(core_intrinsics)]
10 #![feature(rustc_private)]
16 use std::process::Command;
19 // Inlining to avoid llvm turning the recursive functions into tail calls,
20 // which doesn't consume stack.
22 pub fn black_box<T>(dummy: T) { std::intrinsics::black_box(dummy); }
25 let buf = [0u8; 1000];
33 black_box(()); // don't optimize this into a tail call. please.
37 fn check_status(status: std::process::ExitStatus)
39 use std::os::unix::process::ExitStatusExt;
41 assert!(!status.success());
42 assert_eq!(status.signal(), Some(libc::SIGABRT));
46 fn check_status(status: std::process::ExitStatus)
48 assert!(!status.success());
53 let args: Vec<String> = env::args().collect();
54 if args.len() > 1 && args[1] == "silent" {
56 } else if args.len() > 1 && args[1] == "loud" {
58 } else if args.len() > 1 && args[1] == "silent-thread" {
59 thread::spawn(silent_recurse).join();
60 } else if args.len() > 1 && args[1] == "loud-thread" {
61 thread::spawn(loud_recurse).join();
68 // On linux it looks like the main thread can sometimes grow its stack
69 // basically without bounds, so we only test the child thread cases
71 if !cfg!(target_os = "linux") {
76 println!("testing: {}", mode);
78 let silent = Command::new(&args[0]).arg(mode).output().unwrap();
80 check_status(silent.status);
82 let error = String::from_utf8_lossy(&silent.stderr);
83 assert!(error.contains("has overflowed its stack"),
84 "missing overflow message: {}", error);