Skip to content

wasmtime exception preventing export invocation #45

Open
@krisbitney

Description

@krisbitney

Hi,

I am trying to call an exported function. I am getting an opaque wasmtime runtime exception and I can't figure out why. I know the wasm module is correct because we (https://polywrap.io/) have this same invocation working in TypeScript, Rust, and Python. We want to get it working on the JVM as well. The exception is thrown at the actual export.call(...) point, so it seems I have the imports correct and am able to obtain the export reference. But when I call the export function, it fails.

Do you have any advice?

Relevant file in repo (exception thrown at line 36): https://github.com/krisbitney/polywrap-kt/blob/main/src/jvmMain/kotlin/eth.krisbitney.polywrap/wasm/runtime/WasmInstanceJvm.kt

The Wasm module export signature in Rust and AssemblyScript

#[no_mangle]
pub extern "C" fn _wrap_invoke(method_size: u32, args_size: u32, env_size: u32) -> bool
export function _wrap_invoke(method_size: u32, args_size: u32, env_size: u32): bool 

Stacktrace

io.github.kawamuray.wasmtime.WasmtimeException: error while executing at wasm backtrace:
    0: 0xa35a - <unknown>!<wasm function 72>
	at app//io.github.kawamuray.wasmtime.Func.nativeCall(Native Method)
	at app//io.github.kawamuray.wasmtime.Func.call(Func.java:46)
	at app//io.github.kawamuray.wasmtime.Func.call(Func.java:57)
	at app//io.github.kawamuray.wasmtime.WasmFunctions.lambda$func$35(WasmFunctions.java:393)
	at app//eth.krisbitney.polywrap.wasm.runtime.WasmInstanceJvm.invoke-BWLJW6A(WasmInstanceJvm.kt:36)
	at app//eth.krisbitney.polywrap.wasm.WasmWrapper$invoke$2$1.invokeSuspend(WasmWrapper.kt:37)
	at ???(Coroutine boundary.?(?)
	at wasm.WasmWrapperTest$canInvokeWrapper$1.invokeSuspend(WasmWrapperTest.kt:31)
	at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTestCoroutine$2.invokeSuspend(TestBuilders.kt:212)
Caused by: io.github.kawamuray.wasmtime.WasmtimeException: error while executing at wasm backtrace:
    0: 0xa35a - <unknown>!<wasm function 72>
	at app//io.github.kawamuray.wasmtime.Func.nativeCall(Native Method)
	at app//io.github.kawamuray.wasmtime.Func.call(Func.java:46)
	at app//io.github.kawamuray.wasmtime.Func.call(Func.java:57)
	at app//io.github.kawamuray.wasmtime.WasmFunctions.lambda$func$35(WasmFunctions.java:393)
	at app//eth.krisbitney.polywrap.wasm.runtime.WasmInstanceJvm.invoke-BWLJW6A(WasmInstanceJvm.kt:36)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions