2024-02-16 14:02:50 -06:00
|
|
|
//@ run-pass
|
|
|
|
//@ needs-unwind
|
2019-06-29 10:51:44 -05:00
|
|
|
|
2018-08-31 08:02:01 -05:00
|
|
|
#![allow(stable_features)]
|
2019-06-29 10:51:44 -05:00
|
|
|
#![allow(unused_must_use)]
|
2018-08-31 08:02:01 -05:00
|
|
|
|
2024-02-16 14:02:50 -06:00
|
|
|
//@ ignore-emscripten no threads support
|
2016-02-11 05:34:41 -06:00
|
|
|
|
2018-07-22 21:14:42 -05:00
|
|
|
#![feature(std_panic)]
|
|
|
|
|
2015-12-18 01:51:55 -06:00
|
|
|
use std::panic;
|
|
|
|
use std::thread;
|
|
|
|
|
|
|
|
fn a() {
|
2016-03-15 22:38:58 -05:00
|
|
|
panic::set_hook(Box::new(|_| println!("hello yes this is a")));
|
|
|
|
panic::take_hook();
|
|
|
|
panic::set_hook(Box::new(|_| println!("hello yes this is a part 2")));
|
|
|
|
panic::take_hook();
|
2015-12-18 01:51:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn b() {
|
2016-03-15 22:38:58 -05:00
|
|
|
panic::take_hook();
|
|
|
|
panic::take_hook();
|
|
|
|
panic::take_hook();
|
|
|
|
panic::take_hook();
|
|
|
|
panic::take_hook();
|
2015-12-18 01:51:55 -06:00
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn c() {
|
2016-03-15 22:38:58 -05:00
|
|
|
panic::set_hook(Box::new(|_| ()));
|
|
|
|
panic::set_hook(Box::new(|_| ()));
|
|
|
|
panic::set_hook(Box::new(|_| ()));
|
|
|
|
panic::set_hook(Box::new(|_| ()));
|
|
|
|
panic::set_hook(Box::new(|_| ()));
|
|
|
|
panic::set_hook(Box::new(|_| ()));
|
2015-12-18 01:51:55 -06:00
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
for _ in 0..10 {
|
|
|
|
let mut handles = vec![];
|
|
|
|
for _ in 0..10 {
|
|
|
|
handles.push(thread::spawn(a));
|
|
|
|
}
|
|
|
|
for _ in 0..10 {
|
|
|
|
handles.push(thread::spawn(b));
|
|
|
|
}
|
|
|
|
for _ in 0..10 {
|
|
|
|
handles.push(thread::spawn(c));
|
|
|
|
}
|
|
|
|
for handle in handles {
|
|
|
|
let _ = handle.join();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|