aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mem_plan9.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-02-12 10:37:01 -0500
committerAustin Clements <austin@google.com>2015-02-12 16:27:29 +0000
commit27ed1fcb04701477a62cc7cf883a1d64e26e6da9 (patch)
tree53fb2795a657085ad8a02295281d47b1c1ac11c2 /src/runtime/mem_plan9.go
parent3b67e9c29922e3b192113206abd40d983fa2bfe8 (diff)
downloadgo-27ed1fcb04701477a62cc7cf883a1d64e26e6da9.tar.xz
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/4700 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com>
Diffstat (limited to 'src/runtime/mem_plan9.go')
-rw-r--r--src/runtime/mem_plan9.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/mem_plan9.go b/src/runtime/mem_plan9.go
index 477a52700e..6ceed25d87 100644
--- a/src/runtime/mem_plan9.go
+++ b/src/runtime/mem_plan9.go
@@ -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)
}