From d8e6881166e280cc44056f1a6c9747a103dca340 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Fri, 14 Mar 2014 21:22:03 +0400 Subject: [PATCH] runtime: report "out of memory" in efence mode Currently processes crash with obscure message. Say that it's "out of memory". LGTM=rsc R=golang-codereviews CC=golang-codereviews, khr, rsc https://golang.org/cl/75820045 --- src/pkg/runtime/stack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c index 81005de5d7..c0b98634d7 100644 --- a/src/pkg/runtime/stack.c +++ b/src/pkg/runtime/stack.c @@ -102,8 +102,12 @@ runtime·stackalloc(G *gp, uint32 n) runtime·printf("stackalloc %d\n", n); gp->stacksize += n; - if(runtime·debug.efence || StackFromSystem) - return runtime·SysAlloc(ROUND(n, PageSize), &mstats.stacks_sys); + if(runtime·debug.efence || StackFromSystem) { + v = runtime·SysAlloc(ROUND(n, PageSize), &mstats.stacks_sys); + if(v == nil) + runtime·throw("out of memory (stackalloc)"); + return v; + } // Minimum-sized stacks are allocated with a fixed-size free-list allocator, // but if we need a stack of a bigger size, we fall back on malloc -- 2.48.1