Index: src/pkg/runtime/proc.c |
=================================================================== |
--- a/src/pkg/runtime/proc.c |
+++ b/src/pkg/runtime/proc.c |
@@ -2846,9 +2846,12 @@ |
lastgc = runtime·atomicload64(&mstats.last_gc); |
if(lastgc != 0 && unixnow - lastgc > forcegcperiod && runtime·atomicload(&runtime·forcegc.idle)) { |
runtime·lock(&runtime·forcegc.lock); |
- runtime·forcegc.idle = 0; |
- runtime·forcegc.g->schedlink = nil; |
- injectglist(runtime·forcegc.g); |
+ if(runtime·forcegc.g != nil) { |
dvyukov
2014/09/03 03:44:15
there is no race here
this code is executed only
|
+ // Goroutine may be started but has not initialized g yet. |
+ runtime·forcegc.idle = 0; |
+ runtime·forcegc.g->schedlink = nil; |
+ injectglist(runtime·forcegc.g); |
+ } |
runtime·unlock(&runtime·forcegc.lock); |
} |