Skip to content
/ rust Public
forked from rust-lang/rust

Commit

Permalink
Rollup merge of rust-lang#121778 - ibraheemdev:patch-19, r=RalfJung
Browse files Browse the repository at this point in the history
Document potential memory leak in unbounded channel

Follow up on rust-lang#121646.
  • Loading branch information
jhpratt authored Feb 29, 2024
2 parents 3b15e6b + 7c9fa95 commit e392b48
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/std/src/sync/mpmc/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ impl<T> Channel<T> {
}

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

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

0 comments on commit e392b48

Please sign in to comment.