runtime: fix past-the-end write of wasmStack
On Wasm, at program start, we set the SP to wasmStack+sizeof(wasmStack), and start to write on it. This write is actually past the end of wasmStack. This may scribble to some other variable next to it in the data segment. Or if wasmStack happens to be the last object in the data segment, we'll scribble to unreserved memory and cause the next sysReserve return non-zero memory. Either way, this is bad. Fix this by subtracting 16 before writing. Found while debugging the new page allocator (CL 190622 and the stack) with Michael. We found that on Wasm, the first sysReserve may return memory with the first a few words being non-zero. Change-Id: I2d76dd3fee85bddb2ff6a902b5876dea3f2969a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/202086Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Showing
Please register or sign in to comment