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!
@Peter Huene sounds like something you might be able to help with
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
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!
Oh right, I forgot 0.12.0 was released prior. I can see about updating the NuGet package to include EngineBuilder.
Regarding the failure, if you have a repo project I can build or get the Wasm file, I can investigate on Monday.
Awesome, thanks! I'll see if I can extract a good MWE, to share here.
Sorry for the delay, @Peter Huene! Please find an MWE at https://github.com/cgranade/wasm-experiments, thank you again for your help!
Last updated: Dec 23 2024 at 12:05 UTC