Skip to content

Strange symbols don't roundtrip through wasm2wat and wat2wasm #685

Closed

Description

@jtgeibel

Over in alexcrichton/wasm-gc#8 I'm experimenting with demangling rust symbols in wasm output. This results in symbol names such as <alloc::vec::Vec<T>>::extend_from_slice and <&'a T as core::fmt::Debug>::fmt.

While wasm2wat produces very nice looking output, I get a segmentation fault when feeding this output back into wat2wasm. I'm guessing that the space characters are causing issues when parsing the .wat file but other characters could be causing problems as well.

example.wasm.gz

Activity

  1. binji commented on Dec 3, 2017

    @binji
    Member

    Ah, I see! Yeah, this seems to be a limitation of the text format, since any utf-8 sequence is allowed for a name in the binary format. For now, I guess wasm2wat should probably just produce a replacement character.

    I wasn't able to repro the segfault though, here's what I tried:

    $ wasm2wat wasm.gc.wasm -o wasm.gc.wat
    $ wat2wasm wasm.gc.wat
    wasm.gc.wat:82:15: error: unexpected token T, expected ).
      (func $<&'a T as core::fmt::Display>::fmt::h0bee0bd948d5b839 (type 2) (para...
                  ^
    wasm.gc.wat:82:17: error: unexpected token as.
      (func $<&'a T as core::fmt::Display>::fmt::h0bee0bd948d5b839 (type 2) (para...
                    ^^
    wasm.gc.wat:82:20: error: unexpected token core::fmt::Display>::fmt::h0bee0bd948d5b839.
      (func $<&'a T as core::fmt::Display>::fmt::h0bee0bd948d5b839 (type 2) (para...
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    wasm.gc.wat:82:70: error: unexpected token 2, expected (.
    ...::fmt::Display>::fmt::h0bee0bd948d5b839 (type 2) (param i32 i32) (result i32)
                                                     ^
    
  2. keithw commented on May 19, 2022

    @keithw
    Member

    Closing as this no longer segfaults or produces an error, although the question of roundtrippability, and the issue to be fixed by #1661, still seem outstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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