]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: reset scavenge address in scavengeAll
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 26 Nov 2019 21:16:43 +0000 (21:16 +0000)
committerMichael Knyszek <mknyszek@google.com>
Wed, 27 Nov 2019 15:06:55 +0000 (15:06 +0000)
Currently scavengeAll (which is called by debug.FreeOSMemory) doesn't
reset the scavenge address before scavenging, meaning it could miss
large portions of the heap. Fix this by reseting the address before
scavenging, which will ensure it is able to walk over the entire heap.

Fixes #35858.

Change-Id: I4a7408050b8e134318ff94428f98cb96a1795aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/208960
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mheap.go

index 3f3e36728bf943f2ac897565795169d8c18e117e..114c97b874a518deeaf6367f8b4bc08effdf734c 100644 (file)
@@ -1424,6 +1424,8 @@ func (h *mheap) scavengeAll() {
        gp := getg()
        gp.m.mallocing++
        lock(&h.lock)
+       // Reset the scavenger address so we have access to the whole heap.
+       h.pages.resetScavengeAddr()
        released := h.pages.scavenge(^uintptr(0), true)
        unlock(&h.lock)
        gp.m.mallocing--