From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/panics/panic-handler-flail-wildly.rs | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/test/ui/panics/panic-handler-flail-wildly.rs (limited to 'src/test/ui/panics/panic-handler-flail-wildly.rs') diff --git a/src/test/ui/panics/panic-handler-flail-wildly.rs b/src/test/ui/panics/panic-handler-flail-wildly.rs new file mode 100644 index 000000000..679dc7de8 --- /dev/null +++ b/src/test/ui/panics/panic-handler-flail-wildly.rs @@ -0,0 +1,56 @@ +// run-pass +// needs-unwind + +#![allow(stable_features)] +#![allow(unused_must_use)] + +// ignore-emscripten no threads support + +#![feature(std_panic)] + +use std::panic; +use std::thread; + +fn a() { + 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(); +} + +fn b() { + panic::take_hook(); + panic::take_hook(); + panic::take_hook(); + panic::take_hook(); + panic::take_hook(); + panic!(); +} + +fn c() { + 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(|_| ())); + 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(); + } + } +} -- cgit v1.2.3