Stream: wasmtime

Topic: simulating large host implementation


view this post on Zulip Emiel Van Severen (Aug 12 2023 at 11:19):

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(()))
    }

view this post on Zulip Lann Martin (Aug 12 2023 at 13:51):

This, possibly? https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.max_wasm_stack

view this post on Zulip bjorn3 (Aug 13 2023 at 09:11):

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.

view this post on Zulip Emiel Van Severen (Aug 13 2023 at 17:51):

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?

view this post on Zulip Lann Martin (Aug 13 2023 at 22:50):

Err sorry, I should have linked to the related https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.async_stack_size

view this post on Zulip Emiel Van Severen (Aug 14 2023 at 07:34):

Thank you Lann!


Last updated: Nov 22 2024 at 16:03 UTC