diff options
| author | Zachary S <zasample18+github@gmail.com> | 2024-06-20 23:19:18 -0500 |
|---|---|---|
| committer | Zachary S <zasample18+github@gmail.com> | 2024-06-20 23:19:18 -0500 |
| commit | c36fdeb9a3da04839e0892e1351286881c848e39 (patch) | |
| tree | a62a0345fe1e448851389f03be4b2df467148da0 /library/std/src/sys | |
| parent | bff35313972b0d3e248a39cf5a2d03d916ba56d2 (diff) | |
| download | rust-c36fdeb9a3da04839e0892e1351286881c848e39.tar.gz rust-c36fdeb9a3da04839e0892e1351286881c848e39.zip | |
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.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/pal/common/exit_guard.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/common/exit_guard.rs b/library/std/src/sys/pal/common/exit_guard.rs index 49d3b4a96f0..37c8f97e45d 100644 --- a/library/std/src/sys/pal/common/exit_guard.rs +++ b/library/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 <https://github.com/rust-lang/rust/issues/126600> + /// + /// 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 <https://github.com/rust-lang/rust/issues/126600> /// /// On `unix` (where `libc::exit` may not be thread-safe), ensure that only one Rust thread |
