Skip to content

Commit

Permalink
miri: don't attempt to allocate more than 4GiB of memory
Browse files Browse the repository at this point in the history
It seems that rather than returning a null pointer from `std::alloc::alloc`,
miri will sometimes choose to simply crash the whole program.
  • Loading branch information
fitzgen committed Jun 12, 2024
1 parent 67c3506 commit 68ad4ca
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/wasmtime/src/runtime/vm/sys/miri/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ impl Mmap {
}

pub fn reserve(size: usize) -> Result<Self> {
if size > 1 << 32 {
bail!("failed to allocate memory");
}
let layout = Layout::from_size_align(size, crate::runtime::vm::host_page_size()).unwrap();
let ptr = unsafe { alloc::alloc(layout) };
if ptr.is_null() {
Expand Down

0 comments on commit 68ad4ca

Please sign in to comment.