Stream: general

Topic: increasing stack size


view this post on Zulip Andrew Kelley (Nov 30 2022 at 22:06):

Howdy! Is there a way to ask for more wasm stack space?

Error: failed to run main module `build-release/wasi/bin/zig.wasm`

Caused by:
    0: failed to invoke command default
    1: wasm trap: call stack exhausted
       wasm backtrace:
...

view this post on Zulip Peter Huene (Nov 30 2022 at 22:15):

@Andrew Kelley there is the Config::max_wasm_stack configuration setting that controls how much stack space is allowed (from the very first transition from host to wasm); note that synchronous guests run on the same stack as the host does, so you'll need to ensure that 1) there's enough stack space for OS thread the host/guest are running on too and 2) your host stack usage doesn't contribute to also exceeding the limit

view this post on Zulip Andrew Kelley (Nov 30 2022 at 22:17):

that looks like something the library API has access to yeah? or is there a way to pass that as a flag to the CLI?

view this post on Zulip Peter Huene (Nov 30 2022 at 22:18):

The --max-wasm-stack option should set that config setting

view this post on Zulip Peter Huene (Nov 30 2022 at 22:19):

Note that Wasmtime will not adjust the OS thread stack space, so that value should not exceed it (or realistically come close to doing so since the CLI will also consume some of it)

view this post on Zulip Andrew Kelley (Nov 30 2022 at 22:19):

Thanks!

view this post on Zulip Andrew Kelley (Nov 30 2022 at 22:20):

for what it's worth, wasmtime run --help is missing this setting

view this post on Zulip Alex Crichton (Nov 30 2022 at 22:21):

Note thought that --max-wasm-stack was added quite recently as a CLI option, so if it's not in --help you probably need to update the wasmtime executable

view this post on Zulip Alex Crichton (Nov 30 2022 at 22:21):

I think 3.0.0, the most recent release, is the only one with the flag

view this post on Zulip Andrew Kelley (Nov 30 2022 at 22:22):

aha that makes perfect sense. thanks again :thumbs_up:


Last updated: Nov 22 2024 at 17:03 UTC