From: Dmitriy Vyukov Date: Fri, 14 Mar 2014 17:21:44 +0000 (+0400) Subject: runtime: fix a race in bgsweep X-Git-Tag: go1.3beta1~356 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0da73b9f073b2b1e9b78b3a6f6bc077101a05658;p=gostls13.git runtime: fix a race in bgsweep See the comment for description. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/75670044 --- diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c index 65e51e4d1f..f9d6face09 100644 --- a/src/pkg/runtime/mgc0.c +++ b/src/pkg/runtime/mgc0.c @@ -1906,6 +1906,12 @@ bgsweep(void) runtime·ready(fing); } } + if(!runtime·mheap.sweepdone) { + // It's possible if GC has happened between sweepone has + // returned -1 and gclock lock. + runtime·unlock(&gclock); + continue; + } sweep.parked = true; runtime·parkunlock(&gclock, "GC sweep wait"); }