]> Cypherpunks repositories - gostls13.git/commitdiff
fix gc bug causing make smoketest to die in cmd/gofmt.
authorRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 21:16:28 +0000 (14:16 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 21:16:28 +0000 (14:16 -0700)
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

src/pkg/runtime/amd64/traceback.c
src/pkg/runtime/mgc0.c

index 80e79b0e8b705842997eb3a9a898ac79d1e80748..df4e787a756a5deedbeb48d3c8c88763c52bb894 100644 (file)
@@ -26,6 +26,7 @@ traceback(byte *pc0, byte *sp, G *g)
        for(n=0; n<100; n++) {
                if(pc == (uint64)sys·lessstack) {
                        // pop to earlier stack block
+                       // printf("-- stack jump %p => %p\n", sp, stk->gobuf.sp);
                        pc = (uintptr)stk->gobuf.pc;
                        sp = stk->gobuf.sp;
                        stk = (Stktop*)stk->stackbase;
index 6fea924d83eca76951d8e52b09b43d32267fbfb6..52e36745fb3f1bbf100b3dbedb0330829e0ea29b 100644 (file)
@@ -61,13 +61,16 @@ scanblock(int32 depth, byte *b, int64 n)
 }
 
 static void
-scanstack(G *g)
+scanstack(G *gp)
 {
        Stktop *stk;
        byte *sp;
 
-       sp = g->sched.sp;
-       stk = (Stktop*)g->stackbase;
+       if(gp == g)
+               sp = (byte*)&gp;
+       else
+               sp = gp->sched.sp;
+       stk = (Stktop*)gp->stackbase;
        while(stk) {
                scanblock(0, sp, (byte*)stk - sp);
                sp = stk->gobuf.sp;
@@ -220,7 +223,6 @@ gc(int32 force)
 //printf("gc...\n");
        m->gcing = 1;
        semacquire(&gcsema);
-       gosave(&g->sched);      // update g's stack pointer for scanstack
        stoptheworld();
        if(mheap.Lock.key != 0)
                throw("mheap locked during gc");
@@ -230,7 +232,6 @@ gc(int32 force)
                mstats.next_gc = mstats.inuse_pages+mstats.inuse_pages*gcpercent/100;
        }
        starttheworld();
-       gosave(&g->sched);      // update g's stack pointer for debugging
        semrelease(&gcsema);
        m->gcing = 0;
 }