]> Cypherpunks repositories - gostls13.git/commitdiff
fix bug in stack overflow check.
authorRob Pike <r@golang.org>
Thu, 4 Sep 2008 02:58:46 +0000 (19:58 -0700)
committerRob Pike <r@golang.org>
Thu, 4 Sep 2008 02:58:46 +0000 (19:58 -0700)
if stack is in low memory and frame size is huge, test could wrap around!
fix by omitting test altogether if we know frame is big.

R=gri
OCL=14782
CL=14782

src/cmd/6l/pass.c
test/fixedbugs/bug092.go [moved from test/bugs/bug092.go with 100% similarity]
test/golden.out

index e071f6e1a95ed0de2063ba68bc6585c58882bd0d..fed9495c1773a7c1333b55eba947bbffb065506c 100644 (file)
@@ -669,34 +669,36 @@ dostkoff(void)
                        q = P;
                        if(pmorestack != P)
                        if(!(p->from.scale & NOSPLIT)) {
-                               if(autoffset <= 75) {
-                                       // small stack
-                                       p = appendp(p);
-                                       p->as = ACMPQ;
-                                       p->from.type = D_SP;
-                                       p->to.type = D_INDIR+D_R15;
-                                       
-                               } else {
-                                       // large stack
-                                       p = appendp(p);
-                                       p->as = ALEAQ;
-                                       p->from.type = D_INDIR+D_SP;
-                                       p->from.offset = -(autoffset-75);
-                                       p->to.type = D_AX;
-
+                               if(autoffset < 4096) {  // do we need to call morestack
+                                       if(autoffset <= 75) {
+                                               // small stack
+                                               p = appendp(p);
+                                               p->as = ACMPQ;
+                                               p->from.type = D_SP;
+                                               p->to.type = D_INDIR+D_R15;
+                                               
+                                       } else {
+                                               // large stack
+                                               p = appendp(p);
+                                               p->as = ALEAQ;
+                                               p->from.type = D_INDIR+D_SP;
+                                               p->from.offset = -(autoffset-75);
+                                               p->to.type = D_AX;
+       
+                                               p = appendp(p);
+                                               p->as = ACMPQ;
+                                               p->from.type = D_AX;
+                                               p->to.type = D_INDIR+D_R15;
+                                       }
+       
+                                       // common
                                        p = appendp(p);
-                                       p->as = ACMPQ;
-                                       p->from.type = D_AX;
-                                       p->to.type = D_INDIR+D_R15;
+                                       p->as = AJHI;
+                                       p->to.type = D_BRANCH;
+                                       p->to.offset = 4;
+                                       q = p;
                                }
 
-                               // common
-                               p = appendp(p);
-                               p->as = AJHI;
-                               p->to.type = D_BRANCH;
-                               p->to.offset = 4;
-                               q = p;
-
                                p = appendp(p);
                                p->as = AMOVQ;
                                p->from.type = D_CONST;
similarity index 100%
rename from test/bugs/bug092.go
rename to test/fixedbugs/bug092.go
index da9ff597f32465e2e7774e7ea08ea3dfaebd67aa..fd062fa9a7019717c36aee0d52f14bc0ce9d10d3 100644 (file)
@@ -145,10 +145,6 @@ BUG: fails incorrectly
 =========== bugs/bug090.go
 BUG: compilation succeeds incorrectly
 
-=========== bugs/bug092.go
-BUG should not crash
-$RUNFILE: line 1: PID Illegal instruction     ./$A.out
-
 =========== fixedbugs/bug015.go
 fixedbugs/bug015.go:7: overflow converting constant to <int64>INT64