From 757e0de89f80e89626cc8b7d6e670c0e5ea7f192 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Aug 2013 22:34:06 -0400 Subject: runtime: impose stack size limit The goal is to stop only those programs that would keep going and run the machine out of memory, but before they do that. 1 GB on 64-bit, 250 MB on 32-bit. That seems implausibly large, and it can be adjusted. Fixes #2556. Fixes #4494. Fixes #5173. R=khr, r, dvyukov CC=golang-dev https://golang.org/cl/12541052 --- src/pkg/runtime/panic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/pkg/runtime/panic.c') diff --git a/src/pkg/runtime/panic.c b/src/pkg/runtime/panic.c index 61afbf6e73..4fbbed1071 100644 --- a/src/pkg/runtime/panic.c +++ b/src/pkg/runtime/panic.c @@ -320,8 +320,10 @@ runtime·unwindstack(G *gp, byte *sp) gp->stackbase = top->stackbase; gp->stackguard = top->stackguard; gp->stackguard0 = gp->stackguard; - if(top->free != 0) + if(top->free != 0) { + gp->stacksize -= top->free; runtime·stackfree(stk, top->free); + } } if(sp != nil && (sp < (byte*)gp->stackguard - StackGuard || (byte*)gp->stackbase < sp)) { -- cgit v1.3-5-g9baa