runtime: make out-of-memory failures fatal

Match the Go runtime by terminating instead of unwinding when an
allocator exhausts the heap. Recovering an OOM can leave allocator locks
held and cannot safely continue when the panic path itself needs memory.
This commit is contained in:
Jake Bailey
2026-07-24 10:00:19 -07:00
committed by Ron Evans
parent 7756941f39
commit 9105cce340
4 changed files with 16 additions and 4 deletions
+2 -2
View File
@@ -416,7 +416,7 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {
size += bytesPerBlock - 1
if size < rawSize {
// The size overflowed.
runtimePanicAt(returnAddress(0), "out of memory")
runtimeFatal("out of memory")
}
neededBlocks := size / bytesPerBlock
size = neededBlocks * bytesPerBlock
@@ -465,7 +465,7 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {
// Unfortunately the heap could not be increased. This
// happens on baremetal systems for example (where all
// available RAM has already been dedicated to the heap).
runtimePanicAt(returnAddress(0), "out of memory")
runtimeFatal("out of memory")
}
// Set the block states.