Webassembly抛出-内存访问超出范围

时间:2018-07-18 11:43:47

标签: go memory-management 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)

有时也会出现以下错误,

  

运行时:操作系统分配的内存[0x30000000,0x938ab2fd34000000)不   在可用地址空间中:在可用地址空间之外结束

     

严重错误:   内存预留超出地址空间限制

我使用了默认的WebAssembly。此程序的内存(默认内存为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);
            });

我在这里想念什么吗?

0 个答案:

没有答案