1
0
mirror of https://github.com/golang/go synced 2024-11-25 07:57:56 -07:00

6l: correct logic for morestack choice

The frame that gets allocated is for both
the args and the autos.  If together they
exceed the default frame size, we need to
tell morestack about both so that it allocates
a large enough frame.

Sanity check stack pointer in morestack
to catch similar bugs.

R=ken2
CC=golang-dev
https://golang.org/cl/2609041
This commit is contained in:
Russ Cox 2010-10-20 12:16:39 -07:00
parent 4ae9311174
commit c2b91d4889
2 changed files with 3 additions and 1 deletions

View File

@ -469,7 +469,7 @@ dostkoff(void)
/* 160 comes from 3 calls (3*8) 4 safes (4*8) and 104 guard */ /* 160 comes from 3 calls (3*8) 4 safes (4*8) and 104 guard */
moreconst1 = 0; moreconst1 = 0;
if(autoffset+160 > 4096) if(autoffset+160+textarg > 4096)
moreconst1 = (autoffset+160) & ~7LL; moreconst1 = (autoffset+160) & ~7LL;
moreconst2 = textarg; moreconst2 = textarg;

View File

@ -749,6 +749,8 @@ newstack(void)
args = m->moreargs; args = m->moreargs;
g1 = m->curg; g1 = m->curg;
if(m->morebuf.sp < g1->stackguard - StackGuard)
throw("split stack overflow");
if(frame == 1 && args > 0 && m->morebuf.sp - sizeof(Stktop) - args - 32 > g1->stackguard) { if(frame == 1 && args > 0 && m->morebuf.sp - sizeof(Stktop) - args - 32 > g1->stackguard) {
// special case: called from reflect.call (frame == 1) // special case: called from reflect.call (frame == 1)