Closed saethlin closed 2 months ago
This program (reduced from https://crates.io/crates/ialloc)
fn main() { let layout = std::alloc::Layout::from_size_align(1, 1 << 30).unwrap(); unsafe { std::alloc::alloc(layout); } }
Will ICE with
thread 'rustc' panicked at src/tools/miri/src/shims/foreign_items.rs:475:50: called `Result::unwrap()` on an `Err` value: `1073741824` is too large
This limit is deliberate: https://github.com/rust-lang/rust/blob/5c8459f1eceba84dff8d622768dae556ea7c2495/compiler/rustc_abi/src/lib.rs#L699-L700
// LLVM has a maximal supported alignment of 2^29, we inherit that. pub const MAX: Align = Align { pow2: 29 };
We are not LLVM, so I think this limit is simply wrong for Miri. Should we change the struct in the compiler?
It doesn't seem unreasonable to have some upper bound on supported alignment, so throw_unsup_format! would also be acceptable IMO.
throw_unsup_format!
This program (reduced from https://crates.io/crates/ialloc)
Will ICE with
This limit is deliberate: https://github.com/rust-lang/rust/blob/5c8459f1eceba84dff8d622768dae556ea7c2495/compiler/rustc_abi/src/lib.rs#L699-L700
We are not LLVM, so I think this limit is simply wrong for Miri. Should we change the struct in the compiler?