aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-02-27 22:43:34 -0500
committerRuss Cox <rsc@golang.org>2014-02-27 22:43:34 -0500
commit495b91430f7914b221d7507e60b065733e2d34c4 (patch)
treecf1f9e5d63619d12db82c3f555e8bc20bf0c117e
parent950555c812437f0a4acd5cbb913a64fd328d50aa (diff)
downloadgo-495b91430f7914b221d7507e60b065733e2d34c4.tar.gz
go-495b91430f7914b221d7507e60b065733e2d34c4.zip
[release-branch.go1.2] runtime: fix data race in GC
««« 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
-rw-r--r--src/pkg/runtime/mgc0.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c
index 4b2108ba7a..761f128a85 100644
--- a/src/pkg/runtime/mgc0.c
+++ b/src/pkg/runtime/mgc0.c
@@ -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);
}