Skip to content

WAMR iwasm interpreter produces incorrect output on SIMD WebAssembly module #4173

@khagankhan

Description

@khagankhan

Subject of the issue

WAMR simple interpreter iwasm produces a different result from other runtimes most likely because of SIMD instructions.

Test case

discrepancy.wat.txt

discrepancy.wasm.txt

Please remove .txt extesnions when running the WASM modules.

Your environment

  • uname -a: x86_64
  • lsb_release -a: Ubuntu 22.04.5 LTS
  • iwasm --versions: iwasm 2.2.0
  • Wamr built:
cd /path/to/wasm-micro-runtime/product-mini/platforms/linux/
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make -j

Steps to reproduce

Please download the discrepancy.wat.txt and discrepancy.wasm.txt files. Remove .txt extensions and run it with iwasm:

wasm-micro-runtime/product-mini/platforms/linux/build/iwasm -f _main discrepancy.wasm

Expected behavior

iwasm is supposed to produce value zero (0) as _main return like other runtimes:

wasmtime run --invoke _main discrepancy.wasm
warning: using `--invoke` with a function that returns values is experimental and may break in the future
0

Actual behavior

iwasm differs from other runtimes:

CRC mismatch detected! Wasmer: bf56788d, WABT: bf56788d, Wasmtime: bf56788d, WAMR: 9379f56d, WasmEdge: bf56788d

I reduced the test case and removed the host functions that I have used for differential testing. And I think it stems from SIMD instructions. When you run discrepancy.wasm iwasm will produce 1 instead of 0:

wasm-micro-runtime/product-mini/platforms/linux/build/iwasm -f _main discrepancy.wasm
0x1:i32

Despite shrinking the test case using wasm-tools and manually, the best I got was 200 lines. However, most functions can be easily inlined and unreachable ones may be removed. Please tell me if more info is needed.

Extra Info

Wasmoi fuzzer, an Xsmith-based fuzzer produced the snippet of code that found the issue. https://www.flux.utah.edu/project/xsmith

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions