Skip to content

Commit

Permalink
Document potential memory leak in unbounded channel (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev authored Feb 29, 2024
1 parent 24684f9 commit 1d111dc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crossbeam-channel/src/flavors/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,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 1d111dc

Please sign in to comment.