]> git.lizzy.rs Git - rust.git/blob - src/test/ui/threads-sendsync/issue-24313.rs
Rollup merge of #93112 - pietroalbini:pa-cve-2022-21658-nightly, r=pietroalbini
[rust.git] / src / test / ui / threads-sendsync / issue-24313.rs
1 // run-pass
2 // ignore-emscripten no threads
3 // ignore-sgx no processes
4
5 use std::thread;
6 use std::env;
7 use std::process::Command;
8
9 struct Handle(i32);
10
11 impl Drop for Handle {
12     fn drop(&mut self) { panic!(); }
13 }
14
15 thread_local!(static HANDLE: Handle = Handle(0));
16
17 fn main() {
18     let args = env::args().collect::<Vec<_>>();
19     if args.len() == 1 {
20         let out = Command::new(&args[0]).arg("test").output().unwrap();
21         let stderr = std::str::from_utf8(&out.stderr).unwrap();
22         assert!(stderr.contains("panicked at 'explicit panic'"),
23                 "bad failure message:\n{}\n", stderr);
24     } else {
25         // TLS dtors are not always run on process exit
26         thread::spawn(|| {
27             HANDLE.with(|h| {
28                 println!("{}", h.0);
29             });
30         }).join().unwrap();
31     }
32 }