From 0e8a72b62efa44fa01eccb94d47a051366cb6d17 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 30 Mar 2021 12:21:20 -0700 Subject: [PATCH] runtime: check for sysAlloc failures in pageAlloc Change-Id: I78c5744bb01988f1f599569703d83fd21542ac7a Reviewed-on: https://go-review.googlesource.com/c/go/+/305911 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Michael Knyszek --- src/runtime/mpagealloc.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/mpagealloc.go b/src/runtime/mpagealloc.go index dac1f399690..071f1fc2749 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)