Commit 0da73b9f authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: fix a race in bgsweep

See the comment for description.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75670044
parent b8d40172
...@@ -1906,6 +1906,12 @@ bgsweep(void) ...@@ -1906,6 +1906,12 @@ bgsweep(void)
runtime·ready(fing); runtime·ready(fing);
} }
} }
if(!runtime·mheap.sweepdone) {
// It's possible if GC has happened between sweepone has
// returned -1 and gclock lock.
runtime·unlock(&gclock);
continue;
}
sweep.parked = true; sweep.parked = true;
runtime·parkunlock(&gclock, "GC sweep wait"); runtime·parkunlock(&gclock, "GC sweep wait");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment