mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-14 04:56:49 +00:00
Rollup merge of #121778 - ibraheemdev:patch-19, r=RalfJung
Document potential memory leak in unbounded channel Follow up on https://github.com/rust-lang/rust/pull/121646.
This commit is contained in:
commit
20a1bf6c17
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user