]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix a race in bgsweep
authorDmitriy Vyukov <dvyukov@google.com>
Fri, 14 Mar 2014 17:21:44 +0000 (21:21 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Fri, 14 Mar 2014 17:21:44 +0000 (21:21 +0400)
See the comment for description.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75670044

src/pkg/runtime/mgc0.c

index 65e51e4d1f55c3a06f9f48c179fe77ac67d5f207..f9d6face0955e67e7357c7771c6a4699f6db50fd 100644 (file)
@@ -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");
        }