]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.2] runtime: fix data race in GC
authorRuss Cox <rsc@golang.org>
Fri, 28 Feb 2014 03:43:34 +0000 (22:43 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 28 Feb 2014 03:43:34 +0000 (22:43 -0500)
««« CL 52090045 / 302bdb5b08b1
runtime: fix data race in GC
Fixes #5139.
Update #7065.

R=golang-codereviews, bradfitz, minux.ma
CC=golang-codereviews
https://golang.org/cl/52090045
»»»

LGTM=r
R=golang-codereviews, r
CC=golang-dev
https://golang.org/cl/69790043

src/pkg/runtime/mgc0.c

index 4b2108ba7a12c04fc7ffd779986630a6effa6aea..761f128a85afb44ed5f52e4fc4153bde974479c0 100644 (file)
@@ -1798,6 +1798,8 @@ runtime·memorydump(void)
 void
 runtime·gchelper(void)
 {
+       int32 nproc;
+
        gchelperstart();
 
        // parallel mark for over gc roots
@@ -1814,7 +1816,8 @@ runtime·gchelper(void)
 
        runtime·parfordo(work.sweepfor);
        bufferList[m->helpgc].busy = 0;
-       if(runtime·xadd(&work.ndone, +1) == work.nproc-1)
+       nproc = work.nproc;  // work.nproc can change right after we increment work.ndone
+       if(runtime·xadd(&work.ndone, +1) == nproc-1)
                runtime·notewakeup(&work.alldone);
 }