spr*_*ran 5 memory-management go webassembly
我已按照 blog.gopheracademy.com/advent-2017/go-wasm 上的教程从 golang 语言生成 .wasm 文件。
我在执行程序时遇到以下错误,
/home/user/test >节点 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)
Run Code Online (Sandbox Code Playgroud)
有时也会出现以下错误,
运行时:操作系统分配的内存[0x30000000,0x938ab2fd34000000)不在可用地址空间中:结束在可用地址空间之外
致命错误:内存预留超出地址空间限制
我使用了该程序默认的WebAssembly.Memory(默认内存约为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);
});
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么吗?
| 归档时间: |
|
| 查看次数: |
3766 次 |
| 最近记录: |