Skip to content

Commit fe22159

Browse files
authored
Unrolled build for rust-lang#121778
Rollup merge of rust-lang#121778 - ibraheemdev:patch-19, r=RalfJung Document potential memory leak in unbounded channel Follow up on rust-lang#121646.
2 parents d3d145e + 7c9fa95 commit fe22159

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ impl<T> Channel<T> {
547547
}
548548

549549
let mut head = self.head.index.load(Ordering::Acquire);
550+
// The channel may be uninitialized, so we have to swap to avoid overwriting any sender's attempts
551+
// to initalize the first block before noticing that the receivers disconnected. Late allocations
552+
// will be deallocated by the sender in Drop.
550553
let mut block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel);
551554

552555
// If we're going to be dropping messages we need to synchronize with initialization

0 commit comments

Comments
 (0)