wasmtime-java icon indicating copy to clipboard operation
wasmtime-java copied to clipboard

Is there a MemoryInterop example with C++

Open lanny886 opened this issue 1 year ago • 1 comments

I generate .wasm from cpp with emcc , pass malloc address to java, but can not read value by ByteBuffer, also can not modify value by ByteBuffer when read value in c++ later. By the way, when pass const char* address to java, can read value correctly.

lanny886 avatar Jun 02 '23 06:06 lanny886

wasm module/runtime can read/write from/to linear memory only https://wasmbyexample.dev/examples/webassembly-linear-memory/webassembly-linear-memory.rust.en-us.html so maybe the address you're passing around isn't valid in that regard. Anyway, without more information provided there's too many possibilities to guess. One thing you can do is to try running your wasm module using wasmtime command directly, and if it still fails that is a problem of either wasntime runtime or your compiled wasm module.

kawamuray avatar Jun 06 '23 01:06 kawamuray