Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(971)

Unified Diff: src/pkg/runtime/proc.c

Issue 133470043: code review 133470043: runtime: avoid race with forcegc helper (Closed)
Patch Set: diff -r 70fadda83be4173cb2f6f821179ae02c6138de96 https://code.google.com/p/go/ Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pkg/runtime/proc.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | src/pkg/runtime/proc.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b