Commit 94dc963b authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: fix race condition between GC and setGCPercent

If first GC runs concurrently with setGCPercent,
it can overwrite gcpercent value with default.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/10242047
parent 4bb491b1
......@@ -1974,7 +1974,10 @@ runtime·gc(int32 force)
return;
if(gcpercent == GcpercentUnknown) { // first time through
gcpercent = readgogc();
runtime·lock(&runtime·mheap);
if(gcpercent == GcpercentUnknown)
gcpercent = readgogc();
runtime·unlock(&runtime·mheap);
p = runtime·getenv("GOGCTRACE");
if(p != nil)
......
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