about summary refs log tree commit diff
path: root/library/std
diff options
context:
space:
mode:
authorPetros Angelatos <petrosagg@gmail.com>2025-04-10 11:09:31 +0300
committerPetros Angelatos <petrosagg@gmail.com>2025-04-11 15:23:12 +0300
commit9eb6a5446a4e35f48ad22a5b70a74a8badb9fa0d (patch)
tree3bcee6abce74e4e8578f81b3c38387a587d6ea04 /library/std
parent48f89e7659678f91a68c0c2d868180a0036ab32d (diff)
downloadrust-9eb6a5446a4e35f48ad22a5b70a74a8badb9fa0d.tar.gz
rust-9eb6a5446a4e35f48ad22a5b70a74a8badb9fa0d.zip
sync::mpsc: add miri reproducer of double free
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
Diffstat (limited to 'library/std')
-rw-r--r--library/std/src/sync/mpmc/list.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/sync/mpmc/list.rs b/library/std/src/sync/mpmc/list.rs
index d88914f5291..2dd8f41226d 100644
--- a/library/std/src/sync/mpmc/list.rs
+++ b/library/std/src/sync/mpmc/list.rs
@@ -213,6 +213,11 @@ impl<T> Channel<T> {
                     .compare_exchange(block, new, Ordering::Release, Ordering::Relaxed)
                     .is_ok()
                 {
+                    // This yield point leaves the channel in a half-initialized state where the
+                    // tail.block pointer is set but the head.block is not. This is used to
+                    // facilitate the test in src/tools/miri/tests/pass/issues/issue-139553.rs
+                    #[cfg(miri)]
+                    crate::thread::yield_now();
                     self.head.block.store(new, Ordering::Release);
                     block = new;
                 } else {