Skip to content

Commit 8939b53

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 d4f880f commit 8939b53

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/std/src/sync/mpmc/list.rs

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

0 commit comments

Comments
 (0)