When using the cranelift backend and a static typed host function that returns multi-values of different sizes, when calling the host function from Wasm, the Wasm call panics. Using a dynamic host function, it works.
wasmer version is 4.3.4
Rust version is 1.79.0
$ uname -a
Darwin XXXX 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
Wasm function that uses dynamic host function returns 5 successfully. Wasm function that uses typed host function returns a RuntimeError caused by signal trap HeapAccessOutOfBounds.
Describe the bug
When using the cranelift backend and a static typed host function that returns multi-values of different sizes, when calling the host function from Wasm, the Wasm call panics. Using a dynamic host function, it works.
wasmer version is 4.3.4 Rust version is 1.79.0
Steps to reproduce
Run https://gist.github.com/kay/9715e05168381f3f3a0ff5abf49df578
Expected behavior
Both functions should return 5 successfully
Actual behavior
Wasm function that uses dynamic host function returns 5 successfully. Wasm function that uses typed host function returns a
RuntimeError
caused by signal trapHeapAccessOutOfBounds
.Additional context
This also works correctly when using the
LLVM
backend. These issues look similar but not exactly the same outcome, https://github.com/wasmerio/wasmer/issues/4282 or https://github.com/wasmerio/wasmer/issues/3447.