From b3a3afc9b788597ead21ea4770c9679f31475f40 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Wed, 15 Jan 2014 19:38:08 +0400 Subject: [PATCH] runtime: fix data race in GC Fixes #5139. Update #7065. R=golang-codereviews, bradfitz, minux.ma CC=golang-codereviews https://golang.org/cl/52090045 --- src/pkg/runtime/mgc0.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c index af4ba42a620..5d38db27ba7 100644 --- a/src/pkg/runtime/mgc0.c +++ b/src/pkg/runtime/mgc0.c @@ -1956,6 +1956,8 @@ runtime·memorydump(void) void runtime·gchelper(void) { + int32 nproc; + gchelperstart(); // parallel mark for over gc roots @@ -1972,7 +1974,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); }