mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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
This commit is contained in:
parent
28792f5d83
commit
5daffee17f
1 changed files with 4 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue