Skip to content

Commit 5a66845

Browse files
committed
Auto merge of #2929 - RalfJung:tls-panic, r=RalfJung
add tests for panicky drop in thread_local destructor Adds a test for rust-lang/rust#112285
2 parents 464b3c0 + ad615b6 commit 5a66845

4 files changed

+54
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@error-in-other-file: aborted execution
2+
// Backtraces vary wildly between platforms, we have to normalize away almost the entire thing.
3+
// Full backtraces avoid annoying empty line differences.
4+
//@compile-flags: -Zmiri-backtrace=full
5+
//@normalize-stderr-test: "'main'|'<unnamed>'" -> "$$NAME"
6+
//@normalize-stderr-test: ".*(note|-->|\|).*\n" -> ""
7+
8+
pub struct NoisyDrop {}
9+
10+
impl Drop for NoisyDrop {
11+
fn drop(&mut self) {
12+
panic!("ow");
13+
}
14+
}
15+
16+
thread_local! {
17+
pub static NOISY: NoisyDrop = const { NoisyDrop {} };
18+
}
19+
20+
fn main() {
21+
NOISY.with(|_| ());
22+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
thread $NAME panicked at 'ow', $DIR/thread_local_const_drop_panic.rs:LL:CC
2+
fatal runtime error: thread local panicked on drop
3+
error: abnormal termination: the program aborted execution
4+
5+
error: aborting due to previous error
6+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@error-in-other-file: aborted execution
2+
// Backtraces vary wildly between platforms, we have to normalize away almost the entire thing
3+
//@normalize-stderr-test: "'main'|'<unnamed>'" -> "$$NAME"
4+
//@normalize-stderr-test: ".*(note|-->|\|).*\n" -> ""
5+
6+
pub struct NoisyDrop {}
7+
8+
impl Drop for NoisyDrop {
9+
fn drop(&mut self) {
10+
panic!("ow");
11+
}
12+
}
13+
14+
thread_local! {
15+
pub static NOISY: NoisyDrop = NoisyDrop {};
16+
}
17+
18+
fn main() {
19+
NOISY.with(|_| ());
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
thread $NAME panicked at 'ow', $DIR/thread_local_drop_panic.rs:LL:CC
2+
fatal runtime error: thread local panicked on drop
3+
error: abnormal termination: the program aborted execution
4+
5+
error: aborting due to previous error
6+

0 commit comments

Comments
 (0)