I have followed the tutorial on blog.gopheracademy.com/advent-2017/go-wasm for generating the .wasm file from golang language.
I faced the below error when I execute the program,
/home/user/test > node wasm_exec.js test.wasm
RuntimeError: memory access out of bounds
at memchr (wasm-function[75]:96)
at internal_bytealg.IndexByteString (wasm-function[72]:24)
at runtime.findnull (wasm-function[683]:227)
at runtime.gostring (wasm-function[678]:126)
at runtime.goenvs_unix (wasm-function[604]:639)
at runtime.goenvs (wasm-function[432]:86)
at runtime.schedinit (wasm-function[498]:780)
at runtime.rt0_go (wasm-function[860]:165)
at _rt0_wasm_js (wasm-function[907]:71)
at global.Go.run (/home/user/test/wasm_exec.js:378:24)
Sometimes getting the below error too,
runtime: memory allocated by OS [0x30000000, 0x938ab2fd34000000) not in usable address space: end outside usable address space
fatal error: memory reservation exceeds address space limit
I have used the default WebAssembly.Memory of this program (default memory is around 1033MB).
WebAssembly.instantiate(fs.readFileSync("test.wasm"), go.importObject).then((result) => {
process.on("exit", () => { // Node.js exits if no callback is pending
if (!go.exited) {
console.error("error: all goroutines asleep and no JavaScript callback pending - deadlock!");
process.exit(1);
}
});
result.instance.exports.run()
return go.run(result.instance);
}).catch((err) => {
console.error(err);
go.exited = true;
process.exit(1);
});
Is anything I missed here?