Stream: git-wasmtime

Topic: wasmtime / issue #6919 Different result from other wasm r...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 13:49):

luxinyi0105 opened issue #6919:

Test Case

The given testcase was simply mutated a wasm file, which was obtained by compiling C program generated with Csmith using Emscripten Compiler(Emcc).

The original C program is c_file.c, the compilation results with Emscripten is wasm_file.wasm, and its wat format is wat_file.wat.

We mutated the wat file to change its global.set 0 in line 7627 with local.set 0. The result after mutation is mutated_file.wat, and its wasm format is mutated_file.wasm.

Expected Results

$ wasmtime mutated_file.wasm
checksum = 61D81D2D

Actual Results

$ wasmedge mutated_file.wasm
checksum = 61D81D2D
Error: failed to run main module `mutated_file.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x53b2 - <unknown>!<wasm function 22>
           1: 0x53aa - <unknown>!<wasm function 21>
           2: 0x50e3 - <unknown>!<wasm function 16>
    2: exit with invalid exit status outside of [0..126)

Versions and Environment

Wasmtime version or commit: wasmtime-cli 13.0.0
Operating system: Ubuntu 22.04.1
Architecture: x86_64

Extra Info

I tried to use some other wasm runtimes, such as wasmer and wasmedge to execute the same testcase, they just output the checksum result and do not trigger errors.

It seems that there is something wrong with the “exception handling module”, but I am not sure if the problem lies in wasmtime or other runtime tools due to a lack of understanding of WebAssembly. So the details still need you to confirm. Thanks a lot!

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 13:49):

luxinyi0105 added the bug label to Issue #6919.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 13:51):

luxinyi0105 edited issue #6919:

Test Case

The given testcase was simply mutated a wasm file, which was obtained by compiling C program generated with Csmith using Emscripten Compiler(Emcc).

The original C program is c_file.c, the compilation results with Emscripten is wasm_file.wasm, and its wat format is wat_file.wat.

We mutated the wat file to change its global.set 0 in line 7627 with local.set 0. The result after mutation is mutated_file.wat, and its wasm format is mutated_file.wasm.

Expected Results

$ wasmtime mutated_file.wasm
checksum = 61D81D2D

Actual Results

$ wasmedge mutated_file.wasm
checksum = 61D81D2D
Error: failed to run main module `mutated_file.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x53b2 - <unknown>!<wasm function 22>
           1: 0x53aa - <unknown>!<wasm function 21>
           2: 0x50e3 - <unknown>!<wasm function 16>
    2: exit with invalid exit status outside of [0..126)

Versions and Environment

Wasmtime version or commit: wasmtime-cli 13.0.0
Operating system: Ubuntu 22.04.1
Architecture: x86_64

Extra Info

I tried to use some other wasm runtimes, such as wasmer, wasmedge and wasm-micro-runtime(WAMR) to execute the same testcase, they just output the checksum result and do not trigger errors.

It seems that there is something wrong with the “exception handling module”, but I am not sure if the problem lies in wasmtime or other runtime tools due to a lack of understanding of WebAssembly. So the details still need you to confirm. Thanks a lot!

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 14:37):

alexcrichton commented on issue #6919:

Thanks for the report, but I don't think there's a problem here on our side. The mutated instruction is changing the return value of the function to something totally different, and this function is the main function. This means that main's return value, which was previously 0, is now something totally different. That gets threaded through to proc_exit which has the requirement that the exit status is in the printed range, which presumably the provided status isn't.

My guess is that other runtimes are not validating the exit status at all. Wasmtime does that for portability and platform compatibility and other runtimes may eschew this. The current documentation for proc_exit does not exactly specify what to do here. I can't currently easily find the PR that introduced that condition, but I believe it's been around for awhile in Wasmtime.

If you're curious to push on this further I'd recommend opening an issue with WASI to clarify whether this behavior is still desired and/or should be codified in the documentation. If not we should remove it in Wasmtime. If so other runtimes should be updated.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 14:37):

alexcrichton closed issue #6919:

Test Case

The given testcase was simply mutated a wasm file, which was obtained by compiling C program generated with Csmith using Emscripten Compiler(Emcc).

The original C program is c_file.c, the compilation results with Emscripten is wasm_file.wasm, and its wat format is wat_file.wat.

We mutated the wat file to change its global.set 0 in line 7627 with local.set 0. The result after mutation is mutated_file.wat, and its wasm format is mutated_file.wasm.

Expected Results

$ wasmtime mutated_file.wasm
checksum = 61D81D2D

Actual Results

$ wasmedge mutated_file.wasm
checksum = 61D81D2D
Error: failed to run main module `mutated_file.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x53b2 - <unknown>!<wasm function 22>
           1: 0x53aa - <unknown>!<wasm function 21>
           2: 0x50e3 - <unknown>!<wasm function 16>
    2: exit with invalid exit status outside of [0..126)

Versions and Environment

Wasmtime version or commit: wasmtime-cli 13.0.0
Operating system: Ubuntu 22.04.1
Architecture: x86_64

Extra Info

I tried to use some other wasm runtimes, such as wasmer, wasmedge and wasm-micro-runtime(WAMR) to execute the same testcase, they just output the checksum result and do not trigger errors.

It seems that there is something wrong with the “exception handling module”, but I am not sure if the problem lies in wasmtime or other runtime tools due to a lack of understanding of WebAssembly. So the details still need you to confirm. Thanks a lot!


Last updated: Nov 22 2024 at 17:03 UTC