Skip to content

Commit 17c68d1

Browse files
committed
sync::mpsc: add miri reproducer of double free
Signed-off-by: Petros Angelatos <[email protected]>
1 parent d904053 commit 17c68d1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: std/src/sync/mpmc/list.rs

+5
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ impl<T> Channel<T> {
213213
.compare_exchange(block, new, Ordering::Release, Ordering::Relaxed)
214214
.is_ok()
215215
{
216+
// This yield point leaves the channel in a half-initialized state where the
217+
// tail.block pointer is set but the head.block is not. This is used to
218+
// facilitate the test in src/tools/miri/tests/pass/issues/issue-139553.rs
219+
#[cfg(miri)]
220+
crate::thread::yield_now();
216221
self.head.block.store(new, Ordering::Release);
217222
block = new;
218223
} else {

0 commit comments

Comments
 (0)