Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jtgeibel opened this issue Dec 3, 2017 · 2 comments
Closed

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

jtgeibel opened this issue Dec 3, 2017 · 2 comments

Comments

@jtgeibel
Copy link

jtgeibel commented Dec 3, 2017

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

@binji
Copy link
Member

binji commented Dec 3, 2017

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)
                                                 ^

binji added a commit that referenced this issue Dec 3, 2017
We should add a way to express all names that are valid in the binary
format in the text format. Until then, it's better to be able to
produce a valid `wat` file.

See issue #685.
binji added a commit that referenced this issue Dec 3, 2017
We should add a way to express all names that are valid in the binary
format in the text format. Until then, it's better to be able to
produce a valid `wat` file.

See issue #685.
binji added a commit that referenced this issue Dec 6, 2017
We should add a way to express all names that are valid in the binary
format in the text format. Until then, it's better to be able to
produce a valid `wat` file.

See issue #685.
@keithw
Copy link
Member

keithw commented May 19, 2022

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.

@keithw keithw closed this as completed May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants