]> Cypherpunks repositories - gostls13.git/commitdiff
6l: correct logic for morestack choice
authorRuss Cox <rsc@golang.org>
Wed, 20 Oct 2010 19:16:39 +0000 (12:16 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 20 Oct 2010 19:16:39 +0000 (12:16 -0700)
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

src/cmd/6l/pass.c
src/pkg/runtime/proc.c

index a2a82a18b5f6a4fd1ee73a30f07864551170c3cf..8dc0ed551b674a3e1afa388e90dcacef7a297a0f 100644 (file)
@@ -469,7 +469,7 @@ dostkoff(void)
 
                        /* 160 comes from 3 calls (3*8) 4 safes (4*8) and 104 guard */
                        moreconst1 = 0;
-                       if(autoffset+160 > 4096)
+                       if(autoffset+160+textarg > 4096)
                                moreconst1 = (autoffset+160) & ~7LL;
                        moreconst2 = textarg;
 
index d898b30b37ddf4aa372c7cc00c5cda4e3b930d94..b07b6d67c4da592adf81052370389252cb4e2b6d 100644 (file)
@@ -749,6 +749,8 @@ newstack(void)
        args = m->moreargs;
        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) {
                // special case: called from reflect.call (frame == 1)