diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2019-11-13 16:56:50 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2019-11-15 15:22:54 +0000 |
commit | d183253572461eb0cfa46b847b4abd966deb39df (patch) | |
tree | ca03c10c493bee6a9136543f89e1412fbfbcd24f /src/runtime/mgcscavenge_test.go | |
parent | 4e8d27068df52eb372dc2ba7e929e47850934805 (diff) | |
download | go-d183253572461eb0cfa46b847b4abd966deb39df.tar.gz go-d183253572461eb0cfa46b847b4abd966deb39df.zip |
runtime: check summary before scavenging in fast path
In scavengeOne's fast path, we currently don't check the summary for the
chunk that scavAddr points to, which means that we might accidentally
scavenge unused address space if the previous scavenge moves the
scavAddr into that space. The result of this today is a crash.
This change makes it so that scavengeOne's fast path only happens after
the check, following the comment in mpagealloc.go. It also adds a test
for this case.
Fixes #35465.
Updates #35112.
Change-Id: I861d44ee75e42a0e1f5aaec243bc449228273903
Reviewed-on: https://go-review.googlesource.com/c/go/+/206978
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_test.go')
-rw-r--r-- | src/runtime/mgcscavenge_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/runtime/mgcscavenge_test.go b/src/runtime/mgcscavenge_test.go index b29a4d796a..518d5ab27a 100644 --- a/src/runtime/mgcscavenge_test.go +++ b/src/runtime/mgcscavenge_test.go @@ -373,6 +373,25 @@ func TestPageAllocScavenge(t *testing.T) { BaseChunkIdx + 1: {{0, PallocChunkPages}}, }, }, + "ScavDiscontiguous": { + beforeAlloc: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {}, + BaseChunkIdx + 0xe: {}, + }, + beforeScav: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {{uint(minPages), PallocChunkPages - uint(2*minPages)}}, + BaseChunkIdx + 0xe: {{uint(2 * minPages), PallocChunkPages - uint(2*minPages)}}, + }, + expect: []test{ + {2 * minPages * PageSize, 2 * minPages * PageSize}, + {^uintptr(0), 2 * minPages * PageSize}, + {^uintptr(0), 0}, + }, + afterScav: map[ChunkIdx][]BitRange{ + BaseChunkIdx: {{0, PallocChunkPages}}, + BaseChunkIdx + 0xe: {{0, PallocChunkPages}}, + }, + }, } for name, v := range tests { v := v |