Commit 7729c3f9 authored by Russ Cox's avatar Russ Cox

fix gc bug causing make smoketest to die in cmd/gofmt.

saving of sp was too far away from use in scanstack;
the stack had changed since the sp was saved.

R=r
DELTA=9  (4 added, 2 deleted, 3 changed)
OCL=32232
CL=32237
parent d3888fe8
...@@ -26,6 +26,7 @@ traceback(byte *pc0, byte *sp, G *g) ...@@ -26,6 +26,7 @@ traceback(byte *pc0, byte *sp, G *g)
for(n=0; n<100; n++) { for(n=0; n<100; n++) {
if(pc == (uint64)sys·lessstack) { if(pc == (uint64)sys·lessstack) {
// pop to earlier stack block // pop to earlier stack block
// printf("-- stack jump %p => %p\n", sp, stk->gobuf.sp);
pc = (uintptr)stk->gobuf.pc; pc = (uintptr)stk->gobuf.pc;
sp = stk->gobuf.sp; sp = stk->gobuf.sp;
stk = (Stktop*)stk->stackbase; stk = (Stktop*)stk->stackbase;
......
...@@ -61,13 +61,16 @@ scanblock(int32 depth, byte *b, int64 n) ...@@ -61,13 +61,16 @@ scanblock(int32 depth, byte *b, int64 n)
} }
static void static void
scanstack(G *g) scanstack(G *gp)
{ {
Stktop *stk; Stktop *stk;
byte *sp; byte *sp;
sp = g->sched.sp; if(gp == g)
stk = (Stktop*)g->stackbase; sp = (byte*)&gp;
else
sp = gp->sched.sp;
stk = (Stktop*)gp->stackbase;
while(stk) { while(stk) {
scanblock(0, sp, (byte*)stk - sp); scanblock(0, sp, (byte*)stk - sp);
sp = stk->gobuf.sp; sp = stk->gobuf.sp;
...@@ -220,7 +223,6 @@ gc(int32 force) ...@@ -220,7 +223,6 @@ gc(int32 force)
//printf("gc...\n"); //printf("gc...\n");
m->gcing = 1; m->gcing = 1;
semacquire(&gcsema); semacquire(&gcsema);
gosave(&g->sched); // update g's stack pointer for scanstack
stoptheworld(); stoptheworld();
if(mheap.Lock.key != 0) if(mheap.Lock.key != 0)
throw("mheap locked during gc"); throw("mheap locked during gc");
...@@ -230,7 +232,6 @@ gc(int32 force) ...@@ -230,7 +232,6 @@ gc(int32 force)
mstats.next_gc = mstats.inuse_pages+mstats.inuse_pages*gcpercent/100; mstats.next_gc = mstats.inuse_pages+mstats.inuse_pages*gcpercent/100;
} }
starttheworld(); starttheworld();
gosave(&g->sched); // update g's stack pointer for debugging
semrelease(&gcsema); semrelease(&gcsema);
m->gcing = 0; m->gcing = 0;
} }
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