Stream: wasmtime

Topic: inconsistent errors (wasmtime threading)


view this post on Zulip Andrew Brown (Mar 09 2020 at 17:44):

I am seeing some weird wasmtime/cranelift behavior that hopefully someone can help explain. I have a debug build of wasmtime and I am attempting to run a SIMD wasm file. I can track down the SIMD issues, but what is weird is that back-to-back invocations result in completely different errors:

$ ../wasmtime/target/debug/wasmtime --enable-simd simd.wasm
thread '<unnamed>' panicked at 'assertion failed: ok', cranelift/codegen/src/postopt.rs:353:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

$ ../wasmtime/target/debug/wasmtime --enable-simd simd.wasm
Error: failed to run main module `codecbench-simd.wasm`

Caused by:
    0: WebAssembly failed to compile
    1: Compilation error: function u0:26(i64 vmctx, i64) -> i32 system_v {
    ...
    ; 20 verifier errors detected (see above). Compilation aborted.

Any idea what is going on?

view this post on Zulip Dan Gohman (Mar 09 2020 at 17:47):

Is it connected to the compilation cache? Does --disable-cache affect it?

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:50):

Hm, no; when I add --disable-cache I still get the above error pattern on multiple invocations

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:51):

And it's not exactly "one of the postop error, one of the verifier errors;" when I run it a bunch of times sometimes I see more of one or the other

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:51):

is there any threading in wasmtime?

view this post on Zulip Dan Gohman (Mar 09 2020 at 17:51):

What if you set env RAYON_NUM_THREADS=1?

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:51):

:)

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:52):

Ok, I ran that about 10 times and each time I see the verifier errors

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:53):

so is this something we need to fix in wasmtime or just something to be aware of?

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:54):

Also, I thought the verifier was turned off by default? How am I getting verifier errors?

view this post on Zulip Andrew Brown (Mar 09 2020 at 17:55):

https://github.com/bytecodealliance/wasmtime/blob/c8ab1e293e8457c61e34a74baad6649f446dbdc7/crates/api/src/runtime.rs#L244

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Dan Gohman (Mar 09 2020 at 17:59):

We enable the verifier when cfg!(debug_assertions)

view this post on Zulip Dan Gohman (Mar 09 2020 at 18:00):

(see the .cranelift_debug_verifier(cfg!(debug_assertions)) in src/lib.rs)

view this post on Zulip Dan Gohman (Mar 09 2020 at 18:01):

I think this isn't anything we need to fix. If there's a bug somewhere in the wasm->cranelift->machine code pipeline, that bug can trigger at different times because we do parallel compilation.

view this post on Zulip Dan Gohman (Mar 09 2020 at 18:01):

And we should just fix the bug :-).

view this post on Zulip Andrew Brown (Mar 09 2020 at 18:01):

ok, sounds good

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:20):

@Dan Gohman, thanks for the help above; I made the necessary fixes to get past the verification and postopt errors above but now run into another mysterious issue that may be thread-related:

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:21):

when I run the Wasm SIMD code in wasmtime, wasmtime hangs; from strace

read(3, "\0asm\1\0\0\0\1\204\1\24`\1\177\1\177`\1\177\0`\3\177\177\177\1\177`\4\177\177"..., 37987) = 37986
read(3, "", 1)                          = 0
close(3)                                = 0
brk(NULL)                               = 0x55c08423d000
brk(0x55c084265000)                     = 0x55c084265000
futex(0x55c0842034a8, FUTEX_WAKE_PRIVATE, 2147483647) = 8
futex(0x55c084203450, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x55c084232d58, FUTEX_WAIT_PRIVATE, 0, NULL

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:21):

what could wasmtime be waiting for after loading the Wasm code?

view this post on Zulip Dan Gohman (Mar 09 2020 at 22:23):

I don't know. Is some compilation thread entering an infinite loop?

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:25):

Hm, how could I tell?

view this post on Zulip Dan Gohman (Mar 09 2020 at 22:25):

Can you run wasmtime under a debugger?

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:25):

yes, and then break a few times while running it?

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:26):

to see if it is in the same general region?

view this post on Zulip Dan Gohman (Mar 09 2020 at 22:26):

Let it run until it's hung, and then look at all the threads to see where they are

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:28):

ok, looks like it is in wasmtime_environ...cranelift:rs:210

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:28):

probably the par_iter there?

view this post on Zulip Dan Gohman (Mar 09 2020 at 22:28):

That's the thing running all the threads. Are their any worker threads doing work?

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:30):

yes, two: one is in cranelift-codegen doing some layout renumbering (?) and the other is in WorkerThread::run

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:32):

so codegen is stuck in a loop somehow

view this post on Zulip Dan Gohman (Mar 09 2020 at 22:32):

That sounds likely, yes.

view this post on Zulip Andrew Brown (Mar 09 2020 at 22:32):

ok, let me go down that rabbit hole for a while


Last updated: Dec 23 2024 at 13:07 UTC