aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/panic.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-08-15 22:34:06 -0400
committerRuss Cox <rsc@golang.org>2013-08-15 22:34:06 -0400
commit757e0de89f80e89626cc8b7d6e670c0e5ea7f192 (patch)
tree42b7768f368edc26299146007ebf0777618fa677 /src/pkg/runtime/panic.c
parent205329aaf2ec9aff13c4052f6dfa552e65760ea9 (diff)
downloadgo-757e0de89f80e89626cc8b7d6e670c0e5ea7f192.tar.xz
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
Diffstat (limited to 'src/pkg/runtime/panic.c')
-rw-r--r--src/pkg/runtime/panic.c4
1 files changed, 3 insertions, 1 deletions
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)) {