Skip to content

Parse Exception with Block Type But WABT Successfully Parses It #5951

Closed
@mobsceneZ

Description

@mobsceneZ

Hello there, I recently came across a Wasm module which cannot be parsed by Binaryen:

$ wabt/bin/wasm2wat test.wasm
(module
  (type (;0;) (func (result i32)))
  (type (;1;) (func (param i32) (result i32)))
  (func (;0;) (type 0) (result i32)
    i32.const 1
    block (param i32) (result i32)  ;; label = @1
      i32.const 2
      i32.add
    end)
  (export "param" (func 0)))

When using wasm-dis to parse above wasm module, it encountered following errors:

$ wasm-dis test.wasm
[parse exception: Block requires more values than are available (at 0:48)]
Fatal: error parsing wasm (try --debug for more info)

However, when using wasm2wat provided by WABT, it parsed successfully and wasm-interp runs param function without error:

$ wasm-interp test.wasm -r "param"
param() => i32:3

The binaryen version I tested is 16a5993, which is currently the newest commit version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions