bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly

Home Page:https://wasmtime.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Winch runtime segmentation fault in wasmtime 20.0.0

TerrorJack opened this issue · comments

Reproducer: https://files.catbox.moe/jbsi1b.wasm

When wasmtime-cli-v20.0.0 is built with winch on x86_64-linux and the above file is run with wasmtime run -C compiler=winch --env PWD=/ --dir "$PWD"::/ -W tail-call -- hello.wasm, then it fails with a segmentation fault. Remove -C compiler=winch and it properly runs without any issue. The module above does not contain any opcodes unsupported by winch at this time.

Thanks for the report!

A couple of questions that might help diagnose the root cause:

  • The Wasm binary is ~25MB in size, have you tried reducing the failure with wasm-tools shrink as outlined here https://github.com/bytecodealliance/wasmtime/blob/main/docs/contributing-reducing-test-cases.md?
  • Does the Wasm program need access to the current working directory? (e.g. the command in the report is making use of --dir) If so, could you speak a bit more about what are the expectations between the program and that directory? This might make it easier to reduce the program and reproduce the bug in isolation. FWIW, I tried on a Linux machine, without the --env and without the --dir arguments and I get the following result:
main = putStrLn "hello world"

I was able to reproduce, only when the --env, --dir and -W tail-call params are specified (i.e. when -W tail-call is dropped, it doesn't segfault), which makes me think that it has to do with the tail call calling convention and its support in Winch.

FYI, I've opened #8447, to address this issue.