Stream: wasmtime

Topic: one module, many instances?


view this post on Zulip Alex Vidal (May 22 2020 at 16:08):

I'm working on a project that uses the Go bindings for wasmtime, and if I create two instances from the same store, wasi instance, and module I get a call stack exhausted panic when I try to call the entrypoint func. I also tried to construct a new wasi instance for each module instance, but no difference. Am I misunderstanding something?

view this post on Zulip Alex Crichton (May 22 2020 at 16:09):

@Alex Vidal hm what does the stack trace look like?

view this post on Zulip Alex Vidal (May 22 2020 at 16:10):

wasm backtrace: 0: 0xffffffff - <unknown>!_start

view this post on Zulip Alex Vidal (May 22 2020 at 16:12):

In my specific case my wasm program calls out to the host, and the host sleeps for 1s. I can try to repro by sleeping inside the wasm program instead.

view this post on Zulip Alex Vidal (May 22 2020 at 16:12):

(the sleep isn't normal operation, just for my reproduction)

view this post on Zulip Alex Crichton (May 22 2020 at 16:14):

hm is that the only stack frame?

view this post on Zulip Alex Crichton (May 22 2020 at 16:14):

oh you know that actually looks like a segfault

view this post on Zulip Alex Crichton (May 22 2020 at 16:14):

rather than a stack exhausted panic

view this post on Zulip Alex Crichton (May 22 2020 at 16:14):

do you have some code I could poke at?

view this post on Zulip Alex Vidal (May 22 2020 at 16:16):

i can try to reproduce it without all my nonsense

view this post on Zulip Alex Vidal (May 22 2020 at 16:24):

ok i can repro it easily

view this post on Zulip Alex Vidal (May 22 2020 at 16:24):

sending up a branch

view this post on Zulip Alex Vidal (May 22 2020 at 16:28):

https://github.com/avidal/wasmtime-go/blob/concurrent-segfault/repro_test.go

Go WebAssembly runtime powered by Wasmtime. Contribute to avidal/wasmtime-go development by creating an account on GitHub.

view this post on Zulip Alex Vidal (May 22 2020 at 16:30):

the wasi stuff is a red herring it's not necessary for the reproduction

view this post on Zulip Alex Vidal (May 22 2020 at 16:31):

run it with go test -v -run Repro and all but the first subtest will fail

view this post on Zulip Alex Crichton (May 22 2020 at 16:33):

ah I see, so currently nothing in Store can be used concurrently

view this post on Zulip Alex Crichton (May 22 2020 at 16:33):

so believe this is segfaulting due to data races

view this post on Zulip Alex Crichton (May 22 2020 at 16:33):

everything within a Store must be locked to the same goroutine

view this post on Zulip Alex Vidal (May 22 2020 at 16:34):

hm, but i can't get a compiled module without a store..

view this post on Zulip Alex Vidal (May 22 2020 at 16:36):

My program currently instantiates for each incoming http request to avoid the setup costs. I suppose I'll need to use a pool instead and pre-fill it with a handful of stores.

view this post on Zulip Alex Crichton (May 22 2020 at 16:47):

@Alex Vidal ah yeah currently it's a limitation that you need to compile once-per-thread

view this post on Zulip Alex Crichton (May 22 2020 at 16:47):

we very much want to lift that limitation soon

view this post on Zulip Alex Vidal (May 22 2020 at 16:56):

ok cool. I'll setup a pool for now then. Is there a tracking issue I can subscribe to?

view this post on Zulip Alex Crichton (May 22 2020 at 16:58):

https://github.com/bytecodealliance/wasmtime/issues/793 is probably the closest equivalent

Currently as of today the Instance type in the wasmtime crate is not Send. This means that you cannot send it to other threads once it's created. There's a whole bunch of technical issues a...

Last updated: Nov 22 2024 at 16:03 UTC