Stream: git-wasmtime

Topic: wasmtime / issue #7081 Different results while executing ...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2023 at 12:58):

luxinyi0105 opened issue #7081:

Describe the bug

While executing the given testcase with wasmtime and other runtime tools, the results are different.

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 i32.add in line 11788 with i32.sub, and change all the i32/i64.shl with i32/i64.xor. The result after mutation is mutated_file.wat, and its wasm format is mutated_file.wasm.

Expected Results

$ wasmtime mutated_file.wasm
checksum = CF2196F3

Actual Results

$ wasmtime mutated_file.wasm
checksum = CF2196F3
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: 0x7644 - <unknown>!<wasm function 41>
           1: 0x7bd0 - <unknown>!<wasm function 58>
           2: 0x870c - <unknown>!<wasm function 61>
           3: 0x7e70 - <unknown>!<wasm function 60>
           4: 0x7d09 - <unknown>!<wasm function 59>
           5: 0x8b39 - <unknown>!<wasm function 68>
           6: 0x7544 - <unknown>!<wasm function 40>
           7: 0x56a7 - <unknown>!<wasm function 12>
           8: 0x3f65 - <unknown>!<wasm function 7>
           9: 0x72d9 - <unknown>!<wasm function 34>
          10: 0x7253 - <unknown>!<wasm function 33>
    2: Pointer not aligned to 4: Region { start: 64787, len: 4 }

Versions and Environment

Wasmtime version or commit: wasmtime-cli 14.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 wasmi to execute the same testcase, they just output checksum result without runtime error.

I'm not sure whether the runtime error caused by misaligned pointer here is correct. Or maybe there is something wrong with other runtime tools, such as wasmer, wasmedge and wasmi. The detail still needs you to confirm. Thanks a lot!

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2023 at 12:58):

luxinyi0105 added the bug label to Issue #7081.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2023 at 13:07):

bjorn3 commented on issue #7081:

That error happens when passing a non-aligned pointer to a wasi syscall. Wasi requires aligned pointers, but not every wasi implementation checks this and thus incorrectly accepts it.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2023 at 13:59):

luxinyi0105 commented on issue #7081:

That error happens when passing a non-aligned pointer to a wasi syscall. Wasi requires aligned pointers, but not every wasi implementation checks this and thus incorrectly accepts it.

Thanks for your apply.

Actually, I have already discussed the problem with developers in issue #6768, and also have found some testcases which can trigger runtime error caused by misaligned pointer. However, the execution results of those testcases are different from the situation submitted above.

Firstly, for wasmer, executing testcases that can trigger runtime errors caused by misaligned pointer will result in Aborted(core dumped) which root cause is also due to misaligned pointers.

Secondly, wasmi will output nothing while executing those testcases. I have communicated with the relevant developers in wasmi issue #743, but due to uncertainty, the issue has not been effectively resolved.

The testcase submitted in this issue did not encounter the two situations mentioned above during execution using wasmer and wasmi, while wasmtime still detected pointer misalignment issues. Given this situation, I submitted this issue to determine exactly where the problem lies.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2023 at 14:02):

luxinyi0105 edited a comment on issue #7081:

That error happens when passing a non-aligned pointer to a wasi syscall. Wasi requires aligned pointers, but not every wasi implementation checks this and thus incorrectly accepts it.

Thanks for your apply.

Actually, I have already discussed the problem with developers in issue #6768, and also have found some testcases which can trigger runtime error caused by misaligned pointer. However, the execution results of those testcases are different from the situation submitted above.

Firstly, for wasmer, executing testcases that can trigger runtime errors caused by misaligned pointer will result in Aborted(core dumped) which root cause is also due to misaligned pointers.

Secondly, wasmi will output nothing while executing those testcases. The reason for this output maybe the same as before the wasmtime modification(see detail in issue #6768). I have communicated with the relevant developers in wasmi issue #743, but due to uncertainty, the issue has not been effectively resolved.

The testcase submitted in this issue did not encounter the two situations mentioned above during execution using wasmer and wasmi, while wasmtime still detected pointer misalignment issues. Given this situation, I submitted this issue to determine exactly where the problem lies.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2023 at 14:39):

alexcrichton commented on issue #7081:

Yes if other runtimes aren't generating a trap with this then there's not much that can be done on our end. The pointer here is indeed misaligned so I believe trapping is the correct execution of this program. I'm closing since I don't think this is actionable on our part, but let me know if I should reopen.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2023 at 14:39):

alexcrichton closed issue #7081:

Describe the bug

While executing the given testcase with wasmtime and other runtime tools, the results are different.

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 i32.add in line 11788 with i32.sub, and change all the i32/i64.shl with i32/i64.xor. The result after mutation is mutated_file.wat, and its wasm format is mutated_file.wasm.

Expected Results

$ wasmtime mutated_file.wasm
checksum = CF2196F3

Actual Results

$ wasmtime mutated_file.wasm
checksum = CF2196F3
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: 0x7644 - <unknown>!<wasm function 41>
           1: 0x7bd0 - <unknown>!<wasm function 58>
           2: 0x870c - <unknown>!<wasm function 61>
           3: 0x7e70 - <unknown>!<wasm function 60>
           4: 0x7d09 - <unknown>!<wasm function 59>
           5: 0x8b39 - <unknown>!<wasm function 68>
           6: 0x7544 - <unknown>!<wasm function 40>
           7: 0x56a7 - <unknown>!<wasm function 12>
           8: 0x3f65 - <unknown>!<wasm function 7>
           9: 0x72d9 - <unknown>!<wasm function 34>
          10: 0x7253 - <unknown>!<wasm function 33>
    2: Pointer not aligned to 4: Region { start: 64787, len: 4 }

Versions and Environment

Wasmtime version or commit: wasmtime-cli 14.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 wasmi to execute the same testcase, they just output checksum result without runtime error.

I'm not sure whether the runtime error caused by misaligned pointer here is correct. Or maybe there is something wrong with other runtime tools, such as wasmer, wasmedge and wasmi. The detail still needs you to confirm. Thanks a lot!


Last updated: Oct 23 2024 at 20:03 UTC