Skip to content

Commit 63fafe3

Browse files
committed
sync::mpsc: prevent double free on Drop
This PR is fixing a regression introduced by #121646 that can lead to a double free when dropping the channel. The details of the bug can be found in the corresponding crossbeam PR crossbeam-rs/crossbeam#1187 Signed-off-by: Petros Angelatos <[email protected]>
1 parent fe1742a commit 63fafe3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl<T> Channel<T> {
566566
// In that case, just wait until it gets initialized.
567567
while block.is_null() {
568568
backoff.spin_heavy();
569-
block = self.head.block.load(Ordering::Acquire);
569+
block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel);
570570
}
571571
}
572572

0 commit comments

Comments
 (0)