diff --git a/tokio/src/loom/std/atomic_u16.rs b/tokio/src/loom/std/atomic_u16.rs index c9e105c1934..f352e4fae5b 100644 --- a/tokio/src/loom/std/atomic_u16.rs +++ b/tokio/src/loom/std/atomic_u16.rs @@ -23,7 +23,11 @@ impl AtomicU16 { /// All mutations must have happened before the unsynchronized load. /// Additionally, there must be no concurrent mutations. pub(crate) unsafe fn unsync_load(&self) -> u16 { - core::ptr::read(self.inner.get() as *const u16) + // See + #[cfg(miri)] + return self.load(std::sync::atomic::Ordering::Relaxed); + #[cfg(not(miri))] + return core::ptr::read(self.inner.get() as *const u16); } } diff --git a/tokio/src/loom/std/atomic_u32.rs b/tokio/src/loom/std/atomic_u32.rs index ee0d2d38050..422dc789037 100644 --- a/tokio/src/loom/std/atomic_u32.rs +++ b/tokio/src/loom/std/atomic_u32.rs @@ -23,7 +23,11 @@ impl AtomicU32 { /// All mutations must have happened before the unsynchronized load. /// Additionally, there must be no concurrent mutations. pub(crate) unsafe fn unsync_load(&self) -> u32 { - core::ptr::read(self.inner.get() as *const u32) + // See + #[cfg(miri)] + return self.load(std::sync::atomic::Ordering::Relaxed); + #[cfg(not(miri))] + return core::ptr::read(self.inner.get() as *const u32); } } diff --git a/tokio/src/loom/std/atomic_usize.rs b/tokio/src/loom/std/atomic_usize.rs index c5503a2c122..03f2b566550 100644 --- a/tokio/src/loom/std/atomic_usize.rs +++ b/tokio/src/loom/std/atomic_usize.rs @@ -23,7 +23,11 @@ impl AtomicUsize { /// All mutations must have happened before the unsynchronized load. /// Additionally, there must be no concurrent mutations. pub(crate) unsafe fn unsync_load(&self) -> usize { - core::ptr::read(self.inner.get() as *const usize) + // See + #[cfg(miri)] + return self.load(std::sync::atomic::Ordering::Relaxed); + #[cfg(not(miri))] + return core::ptr::read(self.inner.get() as *const usize); } pub(crate) fn with_mut(&mut self, f: impl FnOnce(&mut usize) -> R) -> R {