dotnet-webassembly icon indicating copy to clipboard operation
dotnet-webassembly copied to clipboard

Unknown miscellaneous opcode 10 (0x0a)

Open chutchinson opened this issue 2 years ago • 2 comments

I wrote a trivial hello world program in Rust and then compiled using the wasm32-wasi target. I am working on a WASI implementation and have implemented enough of the WASI spec to execute this Rust program; however, the parser fails while reading the binary module:

WebAssembly.ModuleLoadException: At offset 12463: At offset 12462: Don't know how to parse miscellaneous opcode "10".

I understand that opcode 0x0a is not implemented by the spec (perhaps in a proposal?); so this makes me think either that the module parser has a bug, or the Rust compiler is generating WASM32 code that is not covered by this software.

The Rust program is simply:

fn main() {
    println!("hello world");
}
cargo build --release --target wasm32-wasi

The WAT representation of the module is attached.

sample.txt

I am interested in contributing to this library. It would be awesome to have a WebAssembly runtime native to .NET that leveraged RyuJIT (x86, x64, amd32, amd64). Any guidance on what this issue could be would be a good starting point.

chutchinson avatar Apr 19 '23 06:04 chutchinson

So, after diving into the source code and the WASM spec, this error is referring to the Bulk Memory Operations proposal. After implementing these instructions I can load the module. Section 12 (Data Count) is also part of that proposal.

chutchinson avatar Apr 20 '23 07:04 chutchinson

That makes sense--I haven't been keeping up with all the add-ons after the original 1.0 spec 😅

RyanLamansky avatar May 20 '23 13:05 RyanLamansky