WasmEdge icon indicating copy to clipboard operation
WasmEdge copied to clipboard

bug: There is a lack of out-of-bounds warnings or error messages when executing an out-of-bounds program

Open gaaraw opened this issue 6 months ago • 1 comments

Summary

The same wasm program throws a difference in behavior between different runtime tools: whether to output out of bounds exceptions.

Current State

Wasmedge does not produce any output, wasmtime and WAMR output out of bounds exceptions. The execution is shown in the screenshot.

Expected State

Wasmedge outputs out of bounds exception.

Reproduction steps

test_case_new.zip

Description of the program that caused the exception: The source is from LLVM Test Suite, and the original file mandel-text.wasm is executed normally. After I made one change to mandel-text.wat file, the results made a difference. The change process is as follows:

# mandel-text.wat, line 450
(local.get 4)

replaced with

# test_case_new.wat, line 450-452
(i32.add
    (local.get 3)
    (i32.const 16))

Overall process:

emcc mandel-text.cpp -o mandel-text.wasm -O2 -s WASM=1
wasm2wat -f mandel-text.wasm -o mandel-text.wat
# Replace
wat2wasm test_case_new.wat -o test_case_new.wasm
# Just execute

Environment:

  • wasmtime:wasmtime 35.0.0 (9c2e6f17c 2025-06-17)
  • WAMR:iwasm 2.4.0
  • emcc:4.0.10 (b7dc6e5747465580df5984e723b9d1f10d8e804b)
  • wabt:1.0.27

Screenshots

Image

Any logs you want to share for showing the specific issue

No response

Components

CLI

WasmEdge Version or Commit you used

version 0.14.1

Operating system information

Ubuntu 22.04.5 LTS

Hardware Architecture

x86_64

Compiler flags and options

  • g++:11.4.0
  • cmake:3.22.1
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_TESTS=ON .. && make -j

gaaraw avatar Jul 25 '25 03:07 gaaraw

Hello, I have shortened the wasm file that triggers the diff, and I hope it can help you!

(module
  (type (;0;) (func))
  (type (;1;) (func (param i32 i32 i32) (result i32)))
  (type (;2;) (func (param i32)))
  (type (;3;) (func (param i32 i32 i32 i32) (result i32)))
  (import "wasi_snapshot_preview1" "proc_exit" (func (;0;) (type 2)))
  (import "wasi_snapshot_preview1" "fd_write" (func (;1;) (type 3)))
  (func (;2;) (type 0))
  (func (;3;) (type 0)
    (drop
      (call_indirect (type 1)
        (i32.const 0)
        (i32.const 0)
        (i32.const 0)
        (i32.load
          (i32.const 1068))))
    (call 0
      (i32.const 0))
    (unreachable))
  (func (;4;) (type 1) (param i32 i32 i32) (result i32)
    (i32.store
      (i32.const 20)
      (i32.const -16))
    (drop
      (call 1
        (i32.const 1)
        (i32.const 16)
        (i32.const 1)
        (i32.const 0)))
    (i32.const 0))
  (table (;0;) 5 5 funcref)
  (memory (;0;) 258 258)
  (export "_start" (func 3))
  (export "memory" (memory 0))
  (elem (;0;) (i32.const 1) func 2 2 4)
  (data (;0;) (i32.const 1068) "\03"))

gaaraw avatar Aug 28 '25 01:08 gaaraw