mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: ensure that searchAddr always refers to inUse memory
This change formalizes an assumption made by the page allocator, which is that (*pageAlloc).searchAddr should never refer to memory that is not represented by (*pageAlloc).inUse. The portion of address space covered by (*pageAlloc).inUse reflects the parts of the summary arrays which are guaranteed to mapped, and so looking at any summary which is not reflected there may cause a segfault. In fact, this can happen today. This change thus also removes a micro-optimization which is the only case which may cause (*pageAlloc).searchAddr to point outside of any region covered by (*pageAlloc).inUse, and adds a test verifying that the current segfault can no longer occur. Change-Id: I98b534f0ffba8656d3bd6d782f6fc22549ddf1c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/216697 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
b13ce14c4a
commit
e7f9e17b79
4 changed files with 53 additions and 13 deletions
|
|
@ -225,7 +225,9 @@ type pageAlloc struct {
|
|||
// the bitmaps align better on zero-values.
|
||||
chunks [1 << pallocChunksL1Bits]*[1 << pallocChunksL2Bits]pallocData
|
||||
|
||||
// The address to start an allocation search with.
|
||||
// The address to start an allocation search with. It must never
|
||||
// point to any memory that is not contained in inUse, i.e.
|
||||
// inUse.contains(searchAddr) must always be true.
|
||||
//
|
||||
// When added with arenaBaseOffset, we guarantee that
|
||||
// all valid heap addresses (when also added with
|
||||
|
|
@ -237,7 +239,8 @@ type pageAlloc struct {
|
|||
// space on architectures with segmented address spaces.
|
||||
searchAddr uintptr
|
||||
|
||||
// The address to start a scavenge candidate search with.
|
||||
// The address to start a scavenge candidate search with. It
|
||||
// need not point to memory contained in inUse.
|
||||
scavAddr uintptr
|
||||
|
||||
// The amount of memory scavenged since the last scavtrace print.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue