diff options
| author | Mads Marquart <mads@marquart.dk> | 2024-05-06 07:56:41 +0200 |
|---|---|---|
| committer | Mads Marquart <mads@marquart.dk> | 2024-05-06 08:08:15 +0200 |
| commit | 53bd38b7c5d5dc43feced7cf76904fa5b788de0c (patch) | |
| tree | c54ebb7b3a64366f92162f7cb014c91ffb8504e2 | |
| parent | aa606bb246596dfc6797caa4570025e6f99457c3 (diff) | |
| download | rust-53bd38b7c5d5dc43feced7cf76904fa5b788de0c.tar.gz rust-53bd38b7c5d5dc43feced7cf76904fa5b788de0c.zip | |
iOS/tvOS/watchOS: Fix alloc w. large alignment on older versions
Tested on an old MacBook and the iOS simulator.
| -rw-r--r-- | library/std/src/sys/pal/unix/alloc.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/unix/alloc.rs b/library/std/src/sys/pal/unix/alloc.rs index af0089978ec..9938c0bac25 100644 --- a/library/std/src/sys/pal/unix/alloc.rs +++ b/library/std/src/sys/pal/unix/alloc.rs @@ -13,7 +13,13 @@ unsafe impl GlobalAlloc for System { if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { libc::malloc(layout.size()) as *mut u8 } else { - #[cfg(target_os = "macos")] + // `posix_memalign` returns a non-aligned value if supplied a very + // large alignment on older versions of Apple's platforms (unknown + // exactly which version range, but the issue is definitely + // present in macOS 10.14 and iOS 13.3). + // + // <https://github.com/rust-lang/rust/issues/30170> + #[cfg(target_vendor = "apple")] { if layout.align() > (1 << 31) { return ptr::null_mut(); |
