]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: check for sysAlloc failures in pageAlloc
authorIan Lance Taylor <iant@golang.org>
Tue, 30 Mar 2021 19:21:20 +0000 (12:21 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 31 Mar 2021 03:52:40 +0000 (03:52 +0000)
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>
src/runtime/mpagealloc.go

index dac1f39969090f2d65d73c6f80152806d939a6ab..071f1fc27499cf9f9c043c80c2049f10b1e0c568 100644 (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)