ejrgilbert / whamm

5 stars 2 forks source link

panic when no corresponding event in app wasm #76

Open ahuoguo opened 1 week ago

ahuoguo commented 1 week ago

Consider the following app.wasm

(module
  (type (;0;) (func))
  (type (;1;) (func (param i32 i32) (result i32)))
  (import "bogus" "hi" (func (;0;) (type 1)))
  (func $add (;1;) (type 1) (param i32 i32) (result i32)
    local.get 0
    local.get 1
    i32.add)
  (memory (;0;) 1)
  (export "add" (func 1))
  (export "memory" (memory 0))
)

runned with the following script:

i32 i;
wasm:bytecode:call:before {
    i = 10;
}

This results in a panic in curr_instr_type:

thread 'main' panicked at src/generator/emitters.rs:1476:9:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Seems like the current logic of the tool requires at least one instrument location to not panic.

Change the i32.add to call 0 and there will be no panic.