wabt icon indicating copy to clipboard operation
wabt copied to clipboard

wasm-decompile cannot handle branching out of a function

Open adambenali opened this issue 5 years ago • 0 comments

wasm-decompile fails to decompile the binary corresponding to the following code for instance:

(module
    (func (result i32)
        (block (result i32)
            (i32.const 42)
            (i32.const 1)
            (br_if 1)
        )
    )
)

It fails with the following:

wasm-decompile: wabt/src/ir.h:57: const string& wabt::Var::name() const: Assertion `is_name()' failed.

Trace:

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff7699921 in __GI_abort () at abort.c:79
#2  0x00007ffff768948a in __assert_fail_base (fmt=0x7ffff7810750 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5555557959e9 "is_name()",
    file=file@entry=0x5555557959b8 "wabt/src/ir.h", line=line@entry=57,
    function=function@entry=0x555555795aa0 <wabt::Var::name[abi:cxx11]() const::__PRETTY_FUNCTION__> "const string& wabt::Var::name() const") at assert.c:92
#3  0x00007ffff7689502 in __GI___assert_fail (assertion=0x5555557959e9 "is_name()", file=0x5555557959b8 "wabt/src/ir.h", line=57,
    function=0x555555795aa0 <wabt::Var::name[abi:cxx11]() const::__PRETTY_FUNCTION__> "const string& wabt::Var::name() const") at assert.c:101
#4  0x00005555556c34f7 in wabt::Var::name[abi:cxx11]() const (this=0x555555a70fe0) at wabt/src/ir.h:57
#5  0x00005555557096db in wabt::Decompiler::DecompileExpr (this=0x7fffffffd3b0, n=..., parent=0x555555a71030) at wabt/src/decompiler.cc:552
#6  0x00005555557075c1 in wabt::Decompiler::DecompileExpr (this=0x7fffffffd3b0, n=..., parent=0x555555a711b0) at wabt/src/decompiler.cc:339
#7  0x00005555557075c1 in wabt::Decompiler::DecompileExpr (this=0x7fffffffd3b0, n=..., parent=0x555555a714d0) at wabt/src/decompiler.cc:339
#8  0x00005555557075c1 in wabt::Decompiler::DecompileExpr (this=0x7fffffffd3b0, n=..., parent=0x0) at wabt/src/decompiler.cc:339
#9  0x000055555570b3ad in wabt::Decompiler::Decompile[abi:cxx11]() (this=0x7fffffffd3b0) at wabt/src/decompiler.cc:797
#10 0x00005555557019cc in wabt::Decompile[abi:cxx11](wabt::Module const&, wabt::DecompileOptions const&) (module=..., options=...) at wabt/src/decompiler.cc:826
#11 0x00005555556bcd57 in ProgramMain (argc=2, argv=0x7fffffffdb28) at wabt/src/tools/wasm-decompile.cc:104
#12 0x00005555556bcf23 in main (argc=2, argv=0x7fffffffdb28) at wabt/src/tools/wasm-decompile.cc:117

adambenali avatar Feb 05 '21 21:02 adambenali