aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-03-30 12:21:20 -0700
committerIan Lance Taylor <iant@golang.org>2021-03-31 03:52:40 +0000
commit0e8a72b62efa44fa01eccb94d47a051366cb6d17 (patch)
treeb89f11fd82e270383b878e3640e18157c91f3f94 /src
parentc93cd8614965c6c114671fabf82b69fbd952f52f (diff)
downloadgo-0e8a72b62efa44fa01eccb94d47a051366cb6d17.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mpagealloc.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/mpagealloc.go b/src/runtime/mpagealloc.go
index dac1f39969..071f1fc274 100644
--- a/src/runtime/mpagealloc.go
+++ b/src/runtime/mpagealloc.go
@@ -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)