From a272844a6e163e63ed67047575fba5bb32c951ae Mon Sep 17 00:00:00 2001 From: Zachary S Date: Thu, 20 Jun 2024 23:19:18 -0500 Subject: [PATCH] Don't perform mitigation for thread-unsafe libc::exit under Miri. 1. Miri's exit is thread-safe 2. Miri doesn't (yet) support `libc::gettid`, used in the implementation of the mitigation on Linux. --- std/src/sys/pal/common/exit_guard.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/std/src/sys/pal/common/exit_guard.rs b/std/src/sys/pal/common/exit_guard.rs index 49d3b4a96f073..37c8f97e45d9d 100644 --- a/std/src/sys/pal/common/exit_guard.rs +++ b/std/src/sys/pal/common/exit_guard.rs @@ -1,5 +1,13 @@ cfg_if::cfg_if! { - if #[cfg(target_os = "linux")] { + if #[cfg(miri)] { + /// Mitigation for + /// + /// This mitigation is not necessary when running under Miri, so this function does nothing + /// when running under Miri. + pub(crate) fn unique_thread_exit() { + // Mitigation not required on Miri, where `exit` is thread-safe. + } + } else if #[cfg(target_os = "linux")] { /// Mitigation for /// /// On `unix` (where `libc::exit` may not be thread-safe), ensure that only one Rust thread