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:
commit
6f771c8f44
@ -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(|_| ());
|
||||
}
|
@ -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
|
||||
|
20
src/tools/miri/tests/fail/panic/thread_local_drop_panic.rs
Normal file
20
src/tools/miri/tests/fail/panic/thread_local_drop_panic.rs
Normal 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(|_| ());
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user