title: Webassembly throwing - memory access out of bounds
body: <p>I have followed the tutorial on blog.gopheracademy.com/advent-2017/go-wasm for generating the .wasm file from golang language.</p>
  
  <p>I faced the below error when I execute the program,</p>
  
  <blockquote>
    <p><em>/home/user/test ></em> node wasm_exec.js test.wasm</p>
  </blockquote>
  
  <pre><code>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)
  </code></pre>
  
  <p>Sometimes getting the below error too,</p>
  
  <blockquote>
    <p>runtime: memory allocated by OS [0x30000000, 0x938ab2fd34000000) not
    in usable address space: end outside usable address space </p>
    
    <p>fatal error:
    memory reservation exceeds address space limit</p>
  </blockquote>
  
  <p>I have used the default WebAssembly.Memory of this program (default memory is around 1033MB).</p>
  
  <pre><code>    WebAssembly.instantiate(fs.readFileSync("test.wasm"), go.importObject).then((result) =&gt; {
  process.on("exit", () =&gt; { // 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) =&gt; {
                  console.error(err);
                  go.exited = true;
                  process.exit(1);
              });
  </code></pre>
  
  <p>Is anything I missed here? </p>