Skip to content

Commit 6333ccf

Browse files
committed
iOS/tvOS/watchOS: Fix alloc w. large alignment on older versions
Tested on an old MacBook and the iOS simulator.
1 parent e16bbb8 commit 6333ccf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

std/src/sys/pal/unix/alloc.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ unsafe impl GlobalAlloc for System {
1313
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
1414
libc::malloc(layout.size()) as *mut u8
1515
} else {
16-
#[cfg(target_os = "macos")]
16+
// `posix_memalign` returns a non-aligned value if supplied a very
17+
// large alignment on older versions of Apple's platforms (unknown
18+
// exactly which version range, but the issue is definitely
19+
// present in macOS 10.14 and iOS 13.3).
20+
//
21+
// <https://github.com/rust-lang/rust/issues/30170>
22+
#[cfg(target_vendor = "apple")]
1723
{
1824
if layout.align() > (1 << 31) {
1925
return ptr::null_mut();

0 commit comments

Comments
 (0)