aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/stack.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-03-13 13:16:02 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-03-13 13:16:02 +0400
commit5daffee17fdd8c10ead83a87861d99c39f05561d (patch)
treeaf4d7c75bb24377aa438f7d47bc91f9faea93f9d /src/pkg/runtime/stack.c
parent28792f5d83578d9087be5d3b2490ae8a10e189de (diff)
downloadgo-5daffee17fdd8c10ead83a87861d99c39f05561d.tar.xz
runtime: fix stack size check
When we copy stack, we check only new size of the top segment. This is incorrect, because we can have other segments below it. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, rsc https://golang.org/cl/73980045
Diffstat (limited to 'src/pkg/runtime/stack.c')
-rw-r--r--src/pkg/runtime/stack.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c
index 4bdc24107c..bb7a32f8ae 100644
--- a/src/pkg/runtime/stack.c
+++ b/src/pkg/runtime/stack.c
@@ -662,13 +662,13 @@ runtime·newstack(void)
oldbase = (byte*)gp->stackbase + sizeof(Stktop);
oldsize = oldbase - oldstk;
newsize = oldsize * 2;
- if(newsize > runtime·maxstacksize) {
- runtime·printf("runtime: goroutine stack exceeds %D-byte limit\n", (uint64)runtime·maxstacksize);
- runtime·throw("stack overflow");
- }
copystack(gp, nframes, newsize);
if(StackDebug >= 1)
runtime·printf("stack grow done\n");
+ if(gp->stacksize > runtime·maxstacksize) {
+ runtime·printf("runtime: goroutine stack exceeds %D-byte limit\n", (uint64)runtime·maxstacksize);
+ runtime·throw("stack overflow");
+ }
gp->status = oldstatus;
runtime·gogo(&gp->sched);
}