1
0
mirror of https://github.com/golang/go synced 2024-11-26 05:48:05 -07:00

runtime: check for sysAlloc failures in pageAlloc

Change-Id: I78c5744bb01988f1f599569703d83fd21542ac7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/305911
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Ian Lance Taylor 2021-03-30 12:21:20 -07:00
parent c93cd86149
commit 0e8a72b62e

View File

@ -395,6 +395,9 @@ func (p *pageAlloc) grow(base, size uintptr) {
// Store it atomically to avoid races with readers which
// don't acquire the heap lock.
r := sysAlloc(unsafe.Sizeof(*p.chunks[0]), p.sysStat)
if r == nil {
throw("pageAlloc: out of memory")
}
atomic.StorepNoWB(unsafe.Pointer(&p.chunks[c.l1()]), r)
}
p.chunkOf(c).scavenged.setRange(0, pallocChunkPages)