]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/abi/stack-probes.rs
11 // ignore-cloudabi no processes
12 // ignore-emscripten no processes
13 // ignore-sgx no processes
14 // ignore-musl FIXME #31506
16 use std
::mem
::MaybeUninit
;
17 use std
::process
::Command
;
21 #[link(name = "rust_test_helpers", kind = "static")]
23 #[link_name = "rust_dbg_extern_identity_u64"]
28 let args
= env
::args().skip(1).collect
::<Vec
<_
>>();
31 "main-thread" => recurse(&MaybeUninit
::uninit()),
32 "child-thread" => thread
::spawn(|| recurse(&MaybeUninit
::uninit())).join().unwrap(),
38 let me
= env
::current_exe().unwrap();
40 // The linux kernel has some different behavior for the main thread because
41 // the main thread's stack can typically grow. We can't always guarantee
42 // that we report stack overflow on the main thread, see #43052 for some
44 if cfg
!(not(target_os
= "linux")) {
45 assert_overflow(Command
::new(&me
).arg("main-thread"));
47 assert_overflow(Command
::new(&me
).arg("child-thread"));
50 #[allow(unconditional_recursion)]
51 fn recurse(array
: &MaybeUninit
<[u64; 1024]>) {
53 black_box(array
.as_ptr() as u64);
55 let local
: MaybeUninit
<[u64; 1024]> = MaybeUninit
::uninit();
59 fn assert_overflow(cmd
: &mut Command
) {
60 let output
= cmd
.output().unwrap();
61 assert
!(!output
.status
.success());
62 let stdout
= String
::from_utf8_lossy(&output
.stdout
);
63 let stderr
= String
::from_utf8_lossy(&output
.stderr
);
64 println
!("status: {}", output
.status
);
65 println
!("stdout: {}", stdout
);
66 println
!("stderr: {}", stderr
);
67 assert
!(stdout
.is_empty());
68 assert
!(stderr
.contains("has overflowed its stack\n"));