diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2019-12-26 19:49:39 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2019-12-27 14:52:12 +0000 |
commit | dcd3b2c173b77d93be1c391e3b5f932e0779fb1f (patch) | |
tree | 321f009178270ab01a51d2d2d968147c6472ee6e /src/runtime/mgcscavenge.go | |
parent | 4f757179543e06daec58df6af5884516f8bceb86 (diff) | |
download | go-dcd3b2c173b77d93be1c391e3b5f932e0779fb1f.tar.gz go-dcd3b2c173b77d93be1c391e3b5f932e0779fb1f.zip |
runtime: check whether scavAddr is in inUse on scavengeOne fast path
This change makes it so that we check whether scavAddr is actually
mapped before trying to look at the summary for the fast path, since we
may segfault if that that part of the summary is not mapped in.
Previously this wasn't a problem because we would conservatively map
all memory for the summaries between the lowest mapped heap address and
the highest one.
This change also adds a test for this case.
Change-Id: I2b1d89b5e044dce81745964dfaba829f4becdc57
Reviewed-on: https://go-review.googlesource.com/c/go/+/212637
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/mgcscavenge.go')
-rw-r--r-- | src/runtime/mgcscavenge.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index 752c254ab0..8015bf5d19 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -413,7 +413,10 @@ func (s *pageAlloc) scavengeOne(max uintptr, locked bool) uintptr { // Check the chunk containing the scav addr, starting at the addr // and see if there are any free and unscavenged pages. - if s.summary[len(s.summary)-1][ci].max() >= uint(minPages) { + // + // Only check this if s.scavAddr is covered by any address range + // in s.inUse, so that we know our check of the summary is safe. + if s.inUse.contains(s.scavAddr) && s.summary[len(s.summary)-1][ci].max() >= uint(minPages) { // We only bother looking for a candidate if there at least // minPages free pages at all. It's important that we only // continue if the summary says we can because that's how |