mirror of
https://github.com/golang/go
synced 2024-11-23 02:20:03 -07:00
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/+/202086 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
46aa8354fa
commit
e9c994954f
@ -19,7 +19,7 @@ TEXT _rt0_wasm_js(SB),NOSPLIT,$0
|
||||
// R0: argc (i32)
|
||||
// R1: argv (i32)
|
||||
TEXT wasm_export_run(SB),NOSPLIT,$0
|
||||
MOVD $runtime·wasmStack+m0Stack__size(SB), SP
|
||||
MOVD $runtime·wasmStack+(m0Stack__size-16)(SB), SP
|
||||
|
||||
Get SP
|
||||
Get R0 // argc
|
||||
|
Loading…
Reference in New Issue
Block a user