Skip to content

Crash in SymbolTable::EnsureUnique when name is empty #2595

Open
@thisismiller

Description

@thisismiller

This appears to be caused by the &name[0] in SymbolTable::EnsureUnique while running wat2wasm.

#5  0x000055555556d581 in std::basic_string_view<char, std::char_traits<char> >::operator[] (this=<optimized out>, 
    __pos=<optimized out>) at /usr/include/c++/14/string_view:254
#6  std::basic_string_view<char, std::char_traits<char> >::operator[] (this=0x7fffffffc9f0, __pos=0)
    at /usr/include/c++/14/string_view:254
#7  wabt::(anonymous namespace)::SymbolTable::EnsureUnique (this=this@entry=0x7fffffffcec8, name="")
    at /usr/src/debug/wabt-1.0.36-1.fc41.x86_64/src/binary-writer.cc:236
#8  0x000055555557098a in wabt::(anonymous namespace)::SymbolTable::AddSymbol<wabt::(anonymous namespace)::Symbol::Function> (this=<optimized out>, map=<optimized out>, name="", imported=<optimized out>, exported=<optimized out>, sym=...)
    at /usr/src/debug/wabt-1.0.36-1.fc41.x86_64/src/binary-writer.cc:269
#9  wabt::(anonymous namespace)::SymbolTable::Populate (this=this@entry=0x7fffffffcec8, module=<optimized out>)
    at /usr/src/debug/wabt-1.0.36-1.fc41.x86_64/src/binary-writer.cc:324
#10 0x0000555555576a77 in wabt::(anonymous namespace)::BinaryWriter::WriteModule (this=0x7fffffffceb0)
    at /usr/src/debug/wabt-1.0.36-1.fc41.x86_64/src/binary-writer.cc:1317
#11 0x000055555556a2a0 in wabt::WriteBinaryModule (options=..., stream=0x7fffffffce80, module=<optimized out>)
    at /usr/src/debug/wabt-1.0.36-1.fc41.x86_64/src/binary-writer.cc:1812
#12 ProgramMain (argc=<optimized out>, argv=<optimized out>)
    at /usr/src/debug/wabt-1.0.36-1.fc41.x86_64/src/tools/wat2wasm.cc:155
#13 0x00007ffff7a10248 in __libc_start_call_main (main=main@entry=0x555555555fa0 <main(int, char**)>, argc=argc@entry=5, 
    argv=argv@entry=0x7fffffffd4e8) at ../sysdeps/nptl/libc_start_call_main.h:58
#14 0x00007ffff7a1030b in __libc_start_main_impl (main=0x555555555fa0 <main(int, char**)>, argc=5, argv=0x7fffffffd4e8, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd4d8)
    at ../csu/libc-start.c:360
#15 0x0000555555562e65 in _start ()

This is reproducible by running wast2json on block.wast from the spec, and then doing wasm2wat block.0.wasm -o block.0.wat && wat2wasm -r block.0.wat -o block.0.wasm

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