Stream: general

Topic: debugging wasmtime for .NET CreateModule method


view this post on Zulip Chris Granade (Mar 07 2020 at 02:03):

Hi, I'm new to wasmtime, and am running into some trouble using it from .NET, was hoping to get some help if that's alright. I've got a crate that successfully compiles to a wasm module, and that loads into wasmtime fine, but some modifications to the crate result in a WasmtimeException with the message that the module is invalid. When this happens, wasm-validate --enable-multi-result returns that the module is still correct, but there's no more information from the exception to help debug. Thanks for the help!

view this post on Zulip Till Schneidereit (Mar 07 2020 at 14:29):

@Peter Huene sounds like something you might be able to help with

view this post on Zulip Peter Huene (Mar 07 2020 at 23:57):

Hi @Chris Granade. If you have a Wasm file that makes use of upcoming proposals, like multi-value, you'll need to enable it in the Engine like you would with wasmtime CLI. To do that, use the 0.12.0 release of the .NET package and construct your Engine with an EngineBuilder. An example of doing that can be found here: https://github.com/bytecodealliance/wasmtime/blob/master/crates/misc/dotnet/tests/Fixtures/ModuleFixture.cs#L11-L14

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Chris Granade (Mar 08 2020 at 02:26):

Thanks for the help, @Peter Huene! It looks like the latest version on nuget.org is 0.12.0-preview1, which went before the PR that added EngineBuilder. To resolve that, I tried building from source and that got me a lot futher, but it's still failing with an exception indicating that my module isn't valid. If I patch the c-api crate when building from source to add a panic when loading the wasm module if it's not valid, I can now see the new error after enabling EngineBuilder:

thread '<unnamed>' panicked at 'Section header is too big to fit into section body (at offset 134697)', crates/c-api/src/lib.rs:838:13

For context, the module I'm trying to load was built using cargo-wasi and wasm_bindgen, and passes wasm-validate. Thanks again for the help!

The NuGet Gallery is the central package repository for NuGet, the package manager for .NET.

view this post on Zulip Peter Huene (Mar 08 2020 at 02:31):

Oh right, I forgot 0.12.0 was released prior. I can see about updating the NuGet package to include EngineBuilder.

view this post on Zulip Peter Huene (Mar 08 2020 at 02:32):

Regarding the failure, if you have a repo project I can build or get the Wasm file, I can investigate on Monday.

view this post on Zulip Chris Granade (Mar 08 2020 at 02:36):

Awesome, thanks! I'll see if I can extract a good MWE, to share here.

view this post on Zulip Chris Granade (Mar 09 2020 at 04:20):

Sorry for the delay, @Peter Huene! Please find an MWE at https://github.com/cgranade/wasm-experiments, thank you again for your help!

In which I experiment with different wasm stuff to try and learn some. - cgranade/wasm-experiments

Last updated: Oct 23 2024 at 20:03 UTC