Hello,
I noticed a couple of issues that might be related to mine - I'm not sure if mine's a duplicate of any though, so I'm creating it anyways, hopefully with some useful information and workarounds for others.
I've been trying to use wasm-edit to update .wasm files, but I noticed that it doesn't work and throws a "Invalid UTF-8 encoding" even with the simplest of the outputs from Rust + wasm-bindgen.
Full stacktrace, just in case
```
Error: invalid UTF-8 encoding
at _decode (./node_modules/@webassemblyjs/utf8/lib/decoder.js:43:13)
at Object.decode (./node_modules/@webassemblyjs/utf8/lib/decoder.js:25:10)
at readUTF8String (./node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:229:22)
at parseSection (./node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1671:29)
at Object.decode (./node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1740:25)
at decode (./node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21)
at edit (./node_modules/@webassemblyjs/wasm-edit/lib/index.js:82:36)
```
With that said, there are a couple of flag combinations that I can pass to wasm-bindgen that will remove whatever problematic sections there are, and edit will work just fine.
The smallest set of additional flags I found to do that is --remove-name-section --remove-producers-section –
I'm not sure yet what these are useful for, but I imagine that they would be at least during development? Anyways, i can survive with my workaround for now 🙂
Hello, I noticed a couple of issues that might be related to mine - I'm not sure if mine's a duplicate of any though, so I'm creating it anyways, hopefully with some useful information and workarounds for others.
I've been trying to use wasm-edit to update .wasm files, but I noticed that it doesn't work and throws a "Invalid UTF-8 encoding" even with the simplest of the outputs from Rust + wasm-bindgen.
Full stacktrace, just in case
``` Error: invalid UTF-8 encoding at _decode (./node_modules/@webassemblyjs/utf8/lib/decoder.js:43:13) at Object.decode (./node_modules/@webassemblyjs/utf8/lib/decoder.js:25:10) at readUTF8String (./node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:229:22) at parseSection (./node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1671:29) at Object.decode (./node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1740:25) at decode (./node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21) at edit (./node_modules/@webassemblyjs/wasm-edit/lib/index.js:82:36) ```I also noticed that this doesn't happen if I comment out the call to
shrinkPaddedLEB128
below, or if I useeditWithAST
directly https://github.com/xtuc/webassemblyjs/blob/daf8b9e819103f715285fd22af5832314957eb0d/packages/wasm-edit/src/index.js#L17With that said, there are a couple of flag combinations that I can pass to wasm-bindgen that will remove whatever problematic sections there are, and
edit
will work just fine. The smallest set of additional flags I found to do that is--remove-name-section --remove-producers-section
– I'm not sure yet what these are useful for, but I imagine that they would be at least during development? Anyways, i can survive with my workaround for now 🙂Here's a reproduction repo using
@webassemblyjs/wasm-edit@1.11.6
: https://github.com/gustavohenke/wasm-bindgen-wasm-editThanks in advance!