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
Родитель c93cd86149
Коммит 0e8a72b62e
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

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