Closed MindSwipe closed 1 year ago
Hmm, I got it to work by switching over my C# project which gets compiled to WASM to be an Exe instead of a Library, as well as removing the linker.DefineWasi()
line and stubbing out the WASI methods as described here
You're missing a call to store.SetWasiConfiguration(new WasiConfiguration());
(if the default configuration is acceptable) to configure WASI on the store.
Unfortunately the Wasmtime internals underlying Linker.DefineWasi
will panic if the store has no WASI configuration at instantiation time.
There's no good way for us to improve this experience from the .NET side of things as the callback mechanism by which the linker extracts the WASI configuration from the store is internal to the Wasmtime API and it is expected to panic if the API isn't used properly.
At a bare minimum, we could at least change the unwrap
call in the Wasmtime API to an expect
explaining that a WASI configuration was not set in the store.
I'm trying to compile C# to WASM and then execute that WASM using wasmtime-dotnet but for some reason it panics when trying to invoke the method. Here's the C# code that gets compiled to WASM:
Using some native C to actually get the
SayHello
method to be exported as__say_hello
(I got it to work using this issue on the dotnet-wasi-sdk repo), here is that C:I'm then using the following code to try and invoke the
__say_hello
method:This fails with the exception being
SEHException (0x80004005): External component has thrown an exception.
and the console window shows the following before the stacktrace:Calling the function directly with the wasmtime cli using
wasmtime --invoke __say_hello .\myWasm.wasm
results in the following error:I now found this issue on the ASP.NET Core repo where another user had the same' panicked at 'called
condition
default_alc' not met, their fix is calling
_startbefore anything else, this sadly does not fix my problem as calling
_startfrom C# fails with
SEHException (0x80004005): External component has thrown an exception.and Rust
thread 'Option::unwrap()
on aNone
value', crates\c-api\src\linker.rs:105:80`, however it does work when calling it directly using the wasmtime cli.