wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten
https://wasmer.io
MIT License
18.43k stars 789 forks source link

Incorrect result while executing the given testcase #4116

Open luxinyi0105 opened 1 year ago

luxinyi0105 commented 1 year ago

Describe the bug

Wasmer maybe output incorrect result while executing the given testcase.

Actually, the given testcase was simply mutated a wasm file, which was obtained by compiling the C program generated with Csmith using Emscripten compiler(Emcc). You can convert wasm file to wat format with wabt and find the mutation operation in line 2797(add 1 to the i32.const value). Releated files is here.

$ wasmer -vV
wasmer 4.0.0 (6ccf29d 2023-07-24)
binary: wasmer-cli
commit-hash: 6ccf29df1ebab40b3e3e7676ceac7f9deab9a8a3
commit-date: 2023-07-24
host: x86_64-unknown-linux-gnu
compiler: singlepass,cranelift,llvm
$ rustc -vV
rustc 1.73.0-nightly (0308df23e 2023-07-21)
binary: rustc
commit-hash: 0308df23e621e783e31a27ca5beaa01b9df60d4a
commit-date: 2023-07-21
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Steps to reproduce

$ wasmer mutated_file.wasm

Expected behavior

I used some other WebAssembly Runtimes, e.g. Wasmtime and WasmEdge, to execute the same testcase. Their running result is "None".(They do not output anything). So maybe wasmer's expected behavior should be the same.

Actual behavior

$ wasmer mutated_file.wasm
checksum =  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Additional context

...

ptitSeb commented 1 year ago

You seem unsure of the expected behaviour. What does the program compiled to native is outputing?

luxinyi0105 commented 1 year ago

You seem unsure of the expected behaviour. What does the program compiled to native is outputing?

While compiling C program (generated by Csmith) to native or wasm file, the output is a checksum value of "2B81D605". However, the mutation I performed was on the wat format, so I am not sure what the native file corresponding to the mutated file is.

stale[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 days ago

Feel free to reopen the issue if it has been closed by mistake.