Skip to content

Commit b3a3afc

Browse files
committed
runtime: fix data race in GC
Fixes #5139. Update #7065. R=golang-codereviews, bradfitz, minux.ma CC=golang-codereviews https://golang.org/cl/52090045
1 parent 89c9d6b commit b3a3afc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pkg/runtime/mgc0.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,8 @@ runtime·memorydump(void)
19561956
void
19571957
runtime·gchelper(void)
19581958
{
1959+
int32 nproc;
1960+
19591961
gchelperstart();
19601962

19611963
// parallel mark for over gc roots
@@ -1972,7 +1974,8 @@ runtime·gchelper(void)
19721974

19731975
runtime·parfordo(work.sweepfor);
19741976
bufferList[m->helpgc].busy = 0;
1975-
if(runtime·xadd(&work.ndone, +1) == work.nproc-1)
1977+
nproc = work.nproc; // work.nproc can change right after we increment work.ndone
1978+
if(runtime·xadd(&work.ndone, +1) == nproc-1)
19761979
runtime·notewakeup(&work.alldone);
19771980
}
19781981

0 commit comments

Comments
 (0)