Auto merge of #2929 - RalfJung:tls-panic, r=RalfJung

add tests for panicky drop in thread_local destructor

Adds a test for https://github.com/rust-lang/rust/issues/112285
This commit is contained in:
bors 2023-06-16 10:18:38 +00:00
commit 6f771c8f44
4 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,22 @@
//@error-in-other-file: aborted execution
// Backtraces vary wildly between platforms, we have to normalize away almost the entire thing.
// Full backtraces avoid annoying empty line differences.
//@compile-flags: -Zmiri-backtrace=full
//@normalize-stderr-test: "'main'|'<unnamed>'" -> "$$NAME"
//@normalize-stderr-test: ".*(note|-->|\|).*\n" -> ""
pub struct NoisyDrop {}
impl Drop for NoisyDrop {
fn drop(&mut self) {
panic!("ow");
}
}
thread_local! {
pub static NOISY: NoisyDrop = const { NoisyDrop {} };
}
fn main() {
NOISY.with(|_| ());
}

View File

@ -0,0 +1,6 @@
thread $NAME panicked at 'ow', $DIR/thread_local_const_drop_panic.rs:LL:CC
fatal runtime error: thread local panicked on drop
error: abnormal termination: the program aborted execution
error: aborting due to previous error

View File

@ -0,0 +1,20 @@
//@error-in-other-file: aborted execution
// Backtraces vary wildly between platforms, we have to normalize away almost the entire thing
//@normalize-stderr-test: "'main'|'<unnamed>'" -> "$$NAME"
//@normalize-stderr-test: ".*(note|-->|\|).*\n" -> ""
pub struct NoisyDrop {}
impl Drop for NoisyDrop {
fn drop(&mut self) {
panic!("ow");
}
}
thread_local! {
pub static NOISY: NoisyDrop = NoisyDrop {};
}
fn main() {
NOISY.with(|_| ());
}

View File

@ -0,0 +1,6 @@
thread $NAME panicked at 'ow', $DIR/thread_local_drop_panic.rs:LL:CC
fatal runtime error: thread local panicked on drop
error: abnormal termination: the program aborted execution
error: aborting due to previous error