Commit 27ed1fcb authored by Austin Clements's avatar Austin Clements

runtime: on Plan 9, zero memory returned to the brk by sysFree

Plan 9's sysFree has an optimization where if the object being freed
is the last object allocated, it will roll back the brk to allow the
memory to be reused by sysAlloc.  However, it does not zero this
"returned" memory, so as a result, sysAlloc can return non-zeroed
memory after a sysFree.  This leads to corruption because the runtime
assumes sysAlloc returns zeroed memory.

Fix this by zeroing the memory returned by sysFree.

Fixes #9846.

Change-Id: Id328c58236eb7c464b31ac1da376a0b757a5dc6a
Reviewed-on: https://go-review.googlesource.com/4700Reviewed-by: default avatarRuss Cox <rsc@golang.org>
Reviewed-by: default avatarDavid du Colombier <0intro@gmail.com>
parent 3b67e9c2
......@@ -48,6 +48,7 @@ func sysFree(v unsafe.Pointer, n uintptr, stat *uint64) {
n = memRound(n)
if bloc == uintptr(v)+n {
bloc -= n
memclr(unsafe.Pointer(bloc), n)
}
unlock(&memlock)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment