Commit 6c72bfa5 authored by Rob Pike's avatar Rob Pike

fix bug in stack overflow check.

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
parent f5cb2581
...@@ -669,34 +669,36 @@ dostkoff(void) ...@@ -669,34 +669,36 @@ dostkoff(void)
q = P; q = P;
if(pmorestack != P) if(pmorestack != P)
if(!(p->from.scale & NOSPLIT)) { if(!(p->from.scale & NOSPLIT)) {
if(autoffset <= 75) { if(autoffset < 4096) { // do we need to call morestack
// small stack if(autoffset <= 75) {
p = appendp(p); // small stack
p->as = ACMPQ; p = appendp(p);
p->from.type = D_SP; p->as = ACMPQ;
p->to.type = D_INDIR+D_R15; p->from.type = D_SP;
p->to.type = D_INDIR+D_R15;
} else {
// large stack } else {
p = appendp(p); // large stack
p->as = ALEAQ; p = appendp(p);
p->from.type = D_INDIR+D_SP; p->as = ALEAQ;
p->from.offset = -(autoffset-75); p->from.type = D_INDIR+D_SP;
p->to.type = D_AX; 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 = appendp(p);
p->as = ACMPQ; p->as = AJHI;
p->from.type = D_AX; p->to.type = D_BRANCH;
p->to.type = D_INDIR+D_R15; 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 = appendp(p);
p->as = AMOVQ; p->as = AMOVQ;
p->from.type = D_CONST; p->from.type = D_CONST;
......
...@@ -145,10 +145,6 @@ BUG: fails incorrectly ...@@ -145,10 +145,6 @@ BUG: fails incorrectly
=========== bugs/bug090.go =========== bugs/bug090.go
BUG: compilation succeeds incorrectly 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
fixedbugs/bug015.go:7: overflow converting constant to <int64>INT64 fixedbugs/bug015.go:7: overflow converting constant to <int64>INT64
......
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