diff options
Diffstat (limited to 'src/pkg/runtime/proc.c')
| -rw-r--r-- | src/pkg/runtime/proc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index d1ebd853bb..9229c53a8c 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -2846,9 +2846,12 @@ sysmon(void) 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) { + // 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); } |
