binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

Failed parse for 'attempted pop from empty stack / beyond block start boundary' on non-empty stack

Open aaronmunsters opened this issue 2 years ago • 1 comments

I receive a parse error using wasm-opt v116. The error reports the issue 'attempted pop from empty stack / beyond block start boundary', however the stack is non-empty. The same input program passes wat2wasm and wasm-validate.

Example illustrating what goes wrong:

$ cat instrumented_input.wat

yields

(module
  (func $a (result i32)
    i32.const 0
    i32.const 0
    if (param i32) (result i32)
      drop
      i32.const 0
    else
      drop
      i32.const 0
    end))

however:

# Turn Wat into Wasm
$ wat2wasm instrumented_input.wat -o instrumented_input.wasm

# Validate
$ wasm-validate instrumented_input.wasm # No problem

# Attempt to use wasm-opt
$ wasm-opt --version
wasm-opt version 116
$ wasm-opt instrumented_input.wasm
[parse exception: attempted pop from empty stack / beyond block start boundary at 40 (at 0:40)]
Fatal: error parsing wasm (try --debug for more info)

aaronmunsters avatar Feb 01 '24 15:02 aaronmunsters

if (param i32) (result i32)

Binaryen does not yet support input params to ifs (and other control flow structures).

kripken avatar Feb 01 '24 15:02 kripken

Closing in favor of #6407.

tlively avatar Apr 15 '24 05:04 tlively