Skip to content

Commit b1258bc

Browse files
Merge branch 'master' into comparators
2 parents ec87e01 + 983d56b commit b1258bc

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

crossbeam-channel/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
# Version 0.5.15
2+
3+
- Fix regression introduced in 0.5.12 that can lead to a double free when dropping unbounded channel. (#1187)
4+
15
# Version 0.5.14
26

7+
**Note:** This release has been yanked due to bug fixed in 0.5.15.
8+
39
- Fix stack overflow when sending large value to unbounded channel. (#1146, #1147)
410
- Add `Select::new_biased` function. (#1150)
511
- Remove inefficient spinning. (#1154)
612
- Suppress buggy `clippy::zero_repeat_side_effects` lint in macro generated code. (#1123)
713

814
# Version 0.5.13
915

16+
**Note:** This release has been yanked due to bug fixed in 0.5.15.
17+
1018
- Add `select_biased!` macro. (#1040)
1119

1220
# Version 0.5.12
1321

22+
**Note:** This release has been yanked due to bug fixed in 0.5.15.
23+
1424
- Fix memory leak in unbounded channel. (#1084)
1525

1626
# Version 0.5.11

crossbeam-channel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "crossbeam-channel"
44
# - Update CHANGELOG.md
55
# - Update README.md (when increasing major or minor version)
66
# - Run './tools/publish.sh crossbeam-channel <version>'
7-
version = "0.5.14"
7+
version = "0.5.15"
88
edition = "2021"
99
rust-version = "1.60"
1010
license = "MIT OR Apache-2.0"

crossbeam-channel/src/flavors/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ impl<T> Channel<T> {
613613
// In that case, just wait until it gets initialized.
614614
while block.is_null() {
615615
backoff.snooze();
616-
block = self.head.block.load(Ordering::Acquire);
616+
block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel);
617617
}
618618
}
619619

crossbeam-epoch/src/atomic.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,26 @@ fn ensure_aligned<T: ?Sized + Pointable>(raw: *mut ()) {
6363
/// `tag` is truncated to fit into the unused bits of the pointer to `T`.
6464
#[inline]
6565
fn compose_tag<T: ?Sized + Pointable>(ptr: *mut (), tag: usize) -> *mut () {
66-
int_to_ptr_with_provenance(
67-
(ptr as usize & !low_bits::<T>()) | (tag & low_bits::<T>()),
68-
ptr,
69-
)
66+
map_addr(ptr, |a| (a & !low_bits::<T>()) | (tag & low_bits::<T>()))
7067
}
7168

7269
/// Decomposes a tagged pointer `data` into the pointer and the tag.
7370
#[inline]
7471
fn decompose_tag<T: ?Sized + Pointable>(ptr: *mut ()) -> (*mut (), usize) {
7572
(
76-
int_to_ptr_with_provenance(ptr as usize & !low_bits::<T>(), ptr),
73+
map_addr(ptr, |a| a & !low_bits::<T>()),
7774
ptr as usize & low_bits::<T>(),
7875
)
7976
}
8077

81-
// HACK: https://github.com/rust-lang/miri/issues/1866#issuecomment-985802751
78+
// FIXME: This is exactly <https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.map_addr-1>,
79+
// which we cannot use yet due to the MSRV.
8280
#[inline]
83-
fn int_to_ptr_with_provenance<T>(addr: usize, prov: *mut T) -> *mut T {
84-
let ptr = prov.cast::<u8>();
85-
ptr.wrapping_add(addr.wrapping_sub(ptr as usize)).cast()
81+
fn map_addr<T>(ptr: *mut T, f: impl FnOnce(usize) -> usize) -> *mut T {
82+
let new_addr = f(ptr as usize);
83+
ptr.cast::<u8>()
84+
.wrapping_add(new_addr.wrapping_sub(ptr as usize))
85+
.cast::<T>()
8686
}
8787

8888
/// Types that are pointed to by a single word.
@@ -190,7 +190,6 @@ impl<T> Pointable for T {
190190
/// along with pointer as in `Box<[T]>`).
191191
///
192192
/// Elements are not present in the type, but they will be in the allocation.
193-
/// ```
194193
#[repr(C)]
195194
struct Array<T> {
196195
/// The number of elements (not the number of bytes).
@@ -640,9 +639,7 @@ impl<T: ?Sized + Pointable> Atomic<T> {
640639
let fetch_order = strongest_failure_ordering(order);
641640
Shared::from_ptr(
642641
self.data
643-
.fetch_update(order, fetch_order, |x| {
644-
Some(int_to_ptr_with_provenance(x as usize & val, x))
645-
})
642+
.fetch_update(order, fetch_order, |x| Some(map_addr(x, |a| a & val)))
646643
.unwrap(),
647644
)
648645
}
@@ -687,9 +684,7 @@ impl<T: ?Sized + Pointable> Atomic<T> {
687684
let fetch_order = strongest_failure_ordering(order);
688685
Shared::from_ptr(
689686
self.data
690-
.fetch_update(order, fetch_order, |x| {
691-
Some(int_to_ptr_with_provenance(x as usize | val, x))
692-
})
687+
.fetch_update(order, fetch_order, |x| Some(map_addr(x, |a| a | val)))
693688
.unwrap(),
694689
)
695690
}
@@ -734,9 +729,7 @@ impl<T: ?Sized + Pointable> Atomic<T> {
734729
let fetch_order = strongest_failure_ordering(order);
735730
Shared::from_ptr(
736731
self.data
737-
.fetch_update(order, fetch_order, |x| {
738-
Some(int_to_ptr_with_provenance(x as usize ^ val, x))
739-
})
732+
.fetch_update(order, fetch_order, |x| Some(map_addr(x, |a| a ^ val)))
740733
.unwrap(),
741734
)
742735
}

crossbeam-skiplist/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<K, V> Node<K, V> {
107107
}
108108

109109
ptr::addr_of_mut!((*ptr).refs_and_height)
110-
.write(AtomicUsize::new((height - 1) | ref_count << HEIGHT_BITS));
110+
.write(AtomicUsize::new((height - 1) | (ref_count << HEIGHT_BITS)));
111111
ptr::addr_of_mut!((*ptr).tower.pointers)
112112
.cast::<Atomic<Self>>()
113113
.write_bytes(0, height);

0 commit comments

Comments
 (0)