Skip to content

Commit a272844

Browse files
committed
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.
1 parent 5035a17 commit a272844

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

std/src/sys/pal/common/exit_guard.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
cfg_if::cfg_if! {
2-
if #[cfg(target_os = "linux")] {
2+
if #[cfg(miri)] {
3+
/// Mitigation for <https://github.com/rust-lang/rust/issues/126600>
4+
///
5+
/// This mitigation is not necessary when running under Miri, so this function does nothing
6+
/// when running under Miri.
7+
pub(crate) fn unique_thread_exit() {
8+
// Mitigation not required on Miri, where `exit` is thread-safe.
9+
}
10+
} else if #[cfg(target_os = "linux")] {
311
/// Mitigation for <https://github.com/rust-lang/rust/issues/126600>
412
///
513
/// On `unix` (where `libc::exit` may not be thread-safe), ensure that only one Rust thread

0 commit comments

Comments
 (0)