misc/wasm: fix argv/envp layout
misc/wasm: fix argv/envp layout

The wasm_exec.js wrapper tries to set up the argv and envp following
the UNIX conventions, but doesn't get it quite right, which can cause
runtime.goenv to crash if you get unlucky.

The main problem was that the envp array wasn't terminated with a nil
pointer, so the runtime didn't know when to stop reading the array.
This CL adds that nil pointer to the end of the envp array.

The other problem was harmless, but confusing. In the UNIX convention,
the argv array consists of argc pointers followed by a nil pointer,
followed by the envp array. However, wasm_exec.js put the environment
variable count between the two pointer arrays rather than a nil
pointer. The runtime never looks at this slot, so it didn't matter,
but the break from convention left Cherry and I trying to debug why it
*wasn't* losing any environment variables before we realized that that
layouts happened to be close enough to work. This CL switches to the
UNIX convention of simply terminating the argv array with a nil
pointer.

Change-Id: Ic9a4cd9eabb5dfa599a809b960f9e579b9f1f4db
Reviewed-on: https://go-review.googlesource.com/c/go/+/193417
Run-TryBot: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Cherry Zhang <d62e63aa42ce272d7b6a5055d97e942b33a34679@google.com>
Reviewed-by: Richard Musiol <eb533a4b7e679e5143b37a0022300174aaa46b21@gmail.com>

nawawi/go,akutz/go,golang/go,cloudflare/go,cloudflare/go,akutz/go,akutz/go,akutz/go,golang/go,golang/go,CAFxX/go,cloudflare/go,akutz/go,CAFxX/go,golang/go,nawawi/go,CAFxX/go,CAFxX/go,CAFxX/go,cloudflare/go,nawawi/go,cloudflare/go,golang/go,cloudflare/go,golang/go,nawawi/go,golang/go,nawawi/go,CAFxX/go,akutz/go,CAFxX/go,cloudflare/go,CAFxX/go,akutz/go,nawawi/go,golang/go,nawawi/go,nawawi/go,cloudflare/go,akutz/go