Browse Source

Page align the static memory maximum size (#8630)

This fixes an accidental regression from #8616 where page alignment was
implicitly happening due to how configuration was processed but it
wasn't re-added in the refactoring.
pull/8636/head
Alex Crichton 6 months ago
committed by GitHub
parent
commit
91ec9a589c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      crates/wasmtime/src/config.rs
  2. 11
      tests/all/memory.rs

2
crates/wasmtime/src/config.rs

@ -1368,7 +1368,7 @@ impl Config {
/// for pooling allocation by using memory protection; see
/// `PoolingAllocatorConfig::memory_protection_keys` for details.
pub fn static_memory_maximum_size(&mut self, max_size: u64) -> &mut Self {
self.tunables.static_memory_reservation = Some(max_size);
self.tunables.static_memory_reservation = Some(round_up_to_pages(max_size));
self
}

11
tests/all/memory.rs

@ -658,3 +658,14 @@ fn init_with_negative_segment() -> Result<()> {
Instance::new(&mut store, &module, &[])?;
Ok(())
}
#[test]
fn non_page_aligned_static_memory() -> Result<()> {
let mut config = Config::new();
config.static_memory_maximum_size(100_000);
config.static_memory_forced(true);
let engine = Engine::new(&config)?;
let ty = MemoryType::new(1, None);
Memory::new(&mut Store::new(&engine, ()), ty)?;
Ok(())
}

Loading…
Cancel
Save