Skip to content

Commit 81ff802

Browse files
bors[bot]petrosaggtaiki-e
authored
Merge #973
973: v0.8: Prepare for the next release r=taiki-e a=taiki-e - crossbeam-channel 0.5.7 -> 0.5.8 - Fix race condition in unbounded channel. (#972) Also, yanking `>= 0.5.1, <= 0.5.7` that affected by the bug fixed in this release. Co-authored-by: Petros Angelatos <[email protected]> Co-authored-by: Taiki Endo <[email protected]>
2 parents 721382b + 04fa0aa commit 81ff802

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

crossbeam-channel/CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1+
# Version 0.5.8
2+
3+
- Fix race condition in unbounded channel. (#972)
4+
15
# Version 0.5.7
26

7+
**Note:** This release has been yanked due to bug fixed in 0.5.8.
8+
39
- Improve handling of very large timeout. (#953)
410

511
# Version 0.5.6
612

13+
**Note:** This release has been yanked due to bug fixed in 0.5.8.
14+
715
- Bump the minimum supported Rust version to 1.38. (#877)
816

917
# Version 0.5.5
1018

19+
**Note:** This release has been yanked due to bug fixed in 0.5.8.
20+
1121
- Replace Spinlock with Mutex. (#835)
1222

1323
# Version 0.5.4
1424

25+
**Note:** This release has been yanked due to bug fixed in 0.5.8.
26+
1527
- Workaround a bug in upstream related to TLS access on AArch64 Linux. (#802)
1628

1729
# Version 0.5.3
@@ -28,6 +40,8 @@
2840

2941
# Version 0.5.1
3042

43+
**Note:** This release has been yanked due to bug fixed in 0.5.8.
44+
3145
- Fix memory leak in unbounded channel. (#669)
3246

3347
# Version 0.5.0

crossbeam-channel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "crossbeam-channel"
44
# - Update CHANGELOG.md
55
# - Update README.md
66
# - Create "crossbeam-channel-X.Y.Z" git tag
7-
version = "0.5.7"
7+
version = "0.5.8"
88
edition = "2018"
99
rust-version = "1.38"
1010
license = "MIT OR Apache-2.0"

crossbeam-channel/src/flavors/list.rs

+11
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,17 @@ impl<T> Channel<T> {
584584
let mut head = self.head.index.load(Ordering::Acquire);
585585
let mut block = self.head.block.load(Ordering::Acquire);
586586

587+
// If we're going to be dropping messages we need to synchronize with initialization
588+
if head >> SHIFT != tail >> SHIFT {
589+
// The block can be null here only if a sender is in the process of initializing the
590+
// channel while another sender managed to send a message by inserting it into the
591+
// semi-initialized channel and advanced the tail.
592+
// In that case, just wait until it gets initialized.
593+
while block.is_null() {
594+
backoff.snooze();
595+
block = self.head.block.load(Ordering::Acquire);
596+
}
597+
}
587598
unsafe {
588599
// Drop all messages between head and tail and deallocate the heap-allocated blocks.
589600
while head >> SHIFT != tail >> SHIFT {

0 commit comments

Comments
 (0)