Commit 5daffee1 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

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
parent 28792f5d
...@@ -662,13 +662,13 @@ runtime·newstack(void) ...@@ -662,13 +662,13 @@ runtime·newstack(void)
oldbase = (byte*)gp->stackbase + sizeof(Stktop); oldbase = (byte*)gp->stackbase + sizeof(Stktop);
oldsize = oldbase - oldstk; oldsize = oldbase - oldstk;
newsize = oldsize * 2; 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); copystack(gp, nframes, newsize);
if(StackDebug >= 1) if(StackDebug >= 1)
runtime·printf("stack grow done\n"); 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; gp->status = oldstatus;
runtime·gogo(&gp->sched); runtime·gogo(&gp->sched);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment