]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.15] runtime: fix ReadMemStatsSlow's and CheckScavengedBits' chunk...
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 9 Sep 2020 16:52:18 +0000 (16:52 +0000)
committerDmitri Shuralyov <dmitshur@golang.org>
Thu, 10 Sep 2020 18:38:18 +0000 (18:38 +0000)
commitb1be1428dc7d988c2be9006b1cbdf3e513d299b6
treeecac6792565547680e0a123403a88e3c5d59ca0d
parentbbee5236cd64a11a2bfd194eb9f809f51cae0870
[release-branch.go1.15] runtime: fix ReadMemStatsSlow's and CheckScavengedBits' chunk iteration

Both ReadMemStatsSlow and CheckScavengedBits iterate over the page
allocator's chunks but don't actually check if they exist. During the
development process the chunks index became sparse, so now this was a
possibility. If the runtime tests' heap is sparse we might end up
segfaulting in either one of these functions, though this will generally
be very rare.

The pattern here to return nil for a nonexistent chunk is also useful
elsewhere, so this change introduces tryChunkOf which won't throw, but
might return nil. It also updates the documentation of chunkOf.

For #41296.
Fixes #41317.

Change-Id: Id5ae0ca3234480de1724fdf2e3677eeedcf76fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/253777
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 34835df04891a1d54394888b763af88f9476101d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/253917
src/runtime/export_test.go
src/runtime/mpagealloc.go