3 #![allow(unused_must_use)]
4 #![allow(unconditional_recursion)]
5 #![allow(deprecated)] // llvm_asm!
6 // ignore-android: FIXME (#20004)
7 // ignore-emscripten no processes
8 // ignore-sgx no processes
11 #![feature(rustc_private)]
17 use std::process::Command;
20 // lifted from the test module
21 // Inlining to avoid llvm turning the recursive functions into tail calls,
22 // which doesn't consume stack.
24 pub fn black_box<T>(dummy: T) { unsafe { llvm_asm!("" : : "r"(&dummy)) } }
27 let buf = [0u8; 1000];
35 black_box(()); // don't optimize this into a tail call. please.
39 fn check_status(status: std::process::ExitStatus)
41 use std::os::unix::process::ExitStatusExt;
43 assert!(!status.success());
44 assert_eq!(status.signal(), Some(libc::SIGABRT));
48 fn check_status(status: std::process::ExitStatus)
50 assert!(!status.success());
55 let args: Vec<String> = env::args().collect();
56 if args.len() > 1 && args[1] == "silent" {
58 } else if args.len() > 1 && args[1] == "loud" {
60 } else if args.len() > 1 && args[1] == "silent-thread" {
61 thread::spawn(silent_recurse).join();
62 } else if args.len() > 1 && args[1] == "loud-thread" {
63 thread::spawn(loud_recurse).join();
70 // On linux it looks like the main thread can sometimes grow its stack
71 // basically without bounds, so we only test the child thread cases
73 if !cfg!(target_os = "linux") {
78 println!("testing: {}", mode);
80 let silent = Command::new(&args[0]).arg(mode).output().unwrap();
82 check_status(silent.status);
84 let error = String::from_utf8_lossy(&silent.stderr);
85 assert!(error.contains("has overflowed its stack"),
86 "missing overflow message: {}", error);