]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.14] 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:25 +0000 (18:38 +0000)
commit3b364d9e7e0c1271e547c630960f8f856f22e715
treef96902eae5bfe55cf962e8ed49db07b831036a93
parent77029b76b01fbb4dbeda57664ef62e98efbc2440
[release-branch.go1.14] 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 #41322.

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/+/253922
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/export_test.go
src/runtime/mpagealloc.go