Skip to content

Commit

Permalink
Don't perform mitigation for thread-unsafe libc::exit under Miri.
Browse files Browse the repository at this point in the history
1. Miri's exit is thread-safe
2. Miri doesn't (yet) support `libc::gettid`, used in the implementation of the mitigation on Linux.
  • Loading branch information
zachs18 committed Jun 21, 2024
1 parent 5035a17 commit a272844
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion std/src/sys/pal/common/exit_guard.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit a272844

Please sign in to comment.