]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't run finalizers if we're still on the g0 stack.
authorKeith Randall <khr@golang.org>
Mon, 19 Aug 2013 19:20:50 +0000 (12:20 -0700)
committerKeith Randall <khr@golang.org>
Mon, 19 Aug 2013 19:20:50 +0000 (12:20 -0700)
R=golang-dev, rsc, dvyukov, khr
CC=golang-dev
https://golang.org/cl/11386044

src/pkg/runtime/mgc0.c
src/pkg/runtime/stack.c

index f7162da1f0c5e17580a2d08865806fb273150dbc..0084ca108b1ea4792885de660b1a10dd684c171c 100644 (file)
@@ -2098,7 +2098,7 @@ runtime·gc(int32 force)
        runtime·starttheworld();
        m->locks--;
 
-       // now that gc is done and we're back on g stack, kick off finalizer thread if needed
+       // now that gc is done, kick off finalizer thread if needed
        if(finq != nil) {
                runtime·lock(&finlock);
                // kick off or wake up goroutine to run queued finalizers
@@ -2109,11 +2109,12 @@ runtime·gc(int32 force)
                        runtime·ready(fing);
                }
                runtime·unlock(&finlock);
-               // give the queued finalizers, if any, a chance to run
-               runtime·gosched();
        }
        if(g->preempt)  // restore the preemption request in case we've cleared it in newstack
                g->stackguard0 = StackPreempt;
+       // give the queued finalizers, if any, a chance to run
+       if(g != m->g0)
+               runtime·gosched();
 }
 
 static void
index dd823705da65d217ab13bce3634fe9a3fc8aae01..32d6fd46507963500f781dfe8b5ce25b5333379b 100644 (file)
@@ -105,7 +105,7 @@ runtime·stackalloc(uint32 n)
                m->stackinuse++;
                return v;
        }
-       return runtime·mallocgc(n, 0, FlagNoProfiling|FlagNoGC|FlagNoZero|FlagNoInvokeGC);
+       return runtime·mallocgc(n, 0, FlagNoProfiling|FlagNoGC|FlagNoZero);
 }
 
 void