Open nycki93 opened 2 months ago
fwiw, it seems wasm3-specifc as it doesn't happen with toywasm. https://github.com/aduros/wasm4/pull/749 i haven't tried wasmer.
This was caused by wasm3 bug, the wasm3 runtime requires exactly one memory section: https://github.com/wasm3/wasm3/blob/main/source/m3_parse.c#L460, however, it's legal to have wasm declare 0 memory sections. The fix will be >1
versus !=1
in the above code.
Or build wasm4
using wasmer
as runtime (not tried).
It may be related to how the memory is imported, i.e.
(import "env" "memory" (memory 1))
vs
(memory (import "env" "memory") 1)
The former one will fail due to the fact that @easeway mentioned: there will be no memory in memory section
(import "env" "memory" (memory 1))
vs
(memory (import "env" "memory") 1)
these two are exactly same.
assemblyscript seems to produce an empty memory section, which makes wasm3 unhappy.
other toolchains usually just omits the memory section if a module has no memory defined. wasm3 wrongly assumes this behavior.
steps to reproduce:
w4 version 2.7.0 node version 20.1.0
output:
tested: the cart works in browser with
w4 run cart.wasm
.tested: if the cart is bundled for windows with
w4 bundle cart.wasm --windows cart.exe
then the exe produces the same error as before.tested: removing
"importMemory": true
in asconfig.json seems to fix the issue. is this flag needed?