hi, I'm trying to simulate a large host implementation (component model).
below is one of the functions part of a world, called from the guest.
I'm a bit confused on whats happening here: Bad permissions for mapped region at address 0x6979950.
I expected the static array to just be allocated on the host?
async fn large_static(
&mut self,
) -> std::result::Result<std::result::Result<(), u32>, wasmtime::Error> {
const ARRAY_SIZE: usize = 5 * 1024 * 1024;
static LARGE_STATIC: [u8; ARRAY_SIZE] = [0; ARRAY_SIZE];
black_box(LARGE_STATIC);
Ok(Ok(()))
}
This, possibly? https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.max_wasm_stack
max_wasm_stack is for the wasm value stack which is closer to registers in native architectures. Statics and stack variables that either have their address taken or are too large to fit in a stack entry are stored oj a stack in the linear memory controlled by the wasm module itself. max_wasm_stack doesn't have any effect on this stack. Instead you have to pass a linker argument when linking the wasm module to specify the initial size of the stack.
Correct me if I'm wrong, but this function is an import of the component. Doesn't this allocate memory on the underlying host system, and not in the linear memory of the component's underlying module?
Err sorry, I should have linked to the related https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.async_stack_size
Thank you Lann!
Last updated: Nov 22 2024 at 16:03 UTC