-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@error-in-other-file: aborted execution | ||
|
||
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(|_| ()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
thread '<unnamed>' panicked at 'ow', $DIR/thread_local_const_drop_panic.rs:LL:CC | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
fatal runtime error: thread local panicked on drop | ||
error: abnormal termination: the program aborted execution | ||
--> RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC | ||
| | ||
LL | unsafe { libc::abort() } | ||
| ^^^^^^^^^^^^^ the program aborted execution | ||
| | ||
= note: inside `std::sys::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC | ||
= note: inside `<std::thread::local_impl::abort_on_dtor_unwind::DtorUnwindGuard as std::ops::Drop>::drop` at RUSTLIB/std/src/rt.rs:LL:CC | ||
= note: inside `std::ptr::drop_in_place::<std::thread::local_impl::abort_on_dtor_unwind::DtorUnwindGuard> - shim(Some(std::thread::local_impl::abort_on_dtor_unwind::DtorUnwindGuard))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC | ||
= note: inside `RUSTLIB/std/src/sys/PLATFORM/thread_local/fast_local.rs:LL:CC]>` at RUSTLIB/std/src/sys/PLATFORM/thread_local/mod.rs:LL:CC | ||
note: inside `NOISY::__getit::destroy` | ||
--> $DIR/thread_local_const_drop_panic.rs:LL:CC | ||
| | ||
LL | / thread_local! { | ||
LL | | pub static NOISY: NoisyDrop = const { NoisyDrop {} }; | ||
LL | | } | ||
| |_^ | ||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@error-in-other-file: aborted execution | ||
|
||
pub struct NoisyDrop {} | ||
|
||
impl Drop for NoisyDrop { | ||
fn drop(&mut self) { | ||
panic!("ow"); | ||
} | ||
} | ||
|
||
thread_local! { | ||
pub static NOISY: NoisyDrop = NoisyDrop {}; | ||
} | ||
|
||
fn main() { | ||
NOISY.with(|_| ()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
thread '<unnamed>' panicked at 'ow', $DIR/thread_local_drop_panic.rs:LL:CC | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
fatal runtime error: thread local panicked on drop | ||
error: abnormal termination: the program aborted execution | ||
--> RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC | ||
| | ||
LL | unsafe { libc::abort() } | ||
| ^^^^^^^^^^^^^ the program aborted execution | ||
| | ||
= note: inside `std::sys::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC | ||
= note: inside `std::sys::PLATFORM::thread_local::fast_local::destroy_value::<NoisyDrop>` at RUSTLIB/std/src/rt.rs:LL:CC | ||
= note: inside `std::sys_common::thread_local_dtor::register_dtor_fallback::run_dtors` at RUSTLIB/std/src/sys_common/thread_local_dtor.rs:LL:CC | ||
|
||
error: aborting due to previous error | ||
|