Skip to content

Commit 495b914

Browse files
committed
[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
1 parent 950555c commit 495b914

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pkg/runtime/mgc0.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,8 @@ runtime·memorydump(void)
17981798
void
17991799
runtime·gchelper(void)
18001800
{
1801+
int32 nproc;
1802+
18011803
gchelperstart();
18021804

18031805
// parallel mark for over gc roots
@@ -1814,7 +1816,8 @@ runtime·gchelper(void)
18141816

18151817
runtime·parfordo(work.sweepfor);
18161818
bufferList[m->helpgc].busy = 0;
1817-
if(runtime·xadd(&work.ndone, +1) == work.nproc-1)
1819+
nproc = work.nproc; // work.nproc can change right after we increment work.ndone
1820+
if(runtime·xadd(&work.ndone, +1) == nproc-1)
18181821
runtime·notewakeup(&work.alldone);
18191822
}
18201823

0 commit comments

Comments
 (0)