mirror of https://github.com/golang/go.git
runtime: fix spurious deadlock crashes
Fixes #4243. R=golang-dev, iant CC=golang-dev, sebastien.paolacci https://golang.org/cl/6682050
This commit is contained in:
parent
12cbc8ae31
commit
f24323c93e
|
|
@ -343,6 +343,13 @@ MHeap_FreeLocked(MHeap *h, MSpan *s)
|
|||
runtime·MSpanList_Insert(&h->large, s);
|
||||
}
|
||||
|
||||
static void
|
||||
forcegchelper(Note *note)
|
||||
{
|
||||
runtime·gc(1);
|
||||
runtime·notewakeup(note);
|
||||
}
|
||||
|
||||
// Release (part of) unused memory to OS.
|
||||
// Goroutine created at startup.
|
||||
// Loop forever.
|
||||
|
|
@ -356,7 +363,7 @@ runtime·MHeap_Scavenger(void)
|
|||
uintptr released, sumreleased;
|
||||
byte *env;
|
||||
bool trace;
|
||||
Note note;
|
||||
Note note, *notep;
|
||||
|
||||
// If we go two minutes without a garbage collection, force one to run.
|
||||
forcegc = 2*60*1e9;
|
||||
|
|
@ -385,7 +392,15 @@ runtime·MHeap_Scavenger(void)
|
|||
now = runtime·nanotime();
|
||||
if(now - mstats.last_gc > forcegc) {
|
||||
runtime·unlock(h);
|
||||
runtime·gc(1);
|
||||
// The scavenger can not block other goroutines,
|
||||
// otherwise deadlock detector can fire spuriously.
|
||||
// GC blocks other goroutines via the runtime·worldsema.
|
||||
runtime·noteclear(¬e);
|
||||
notep = ¬e;
|
||||
runtime·newproc1((byte*)forcegchelper, (byte*)¬ep, sizeof(notep), 0, runtime·MHeap_Scavenger);
|
||||
runtime·entersyscall();
|
||||
runtime·notesleep(¬e);
|
||||
runtime·exitsyscall();
|
||||
runtime·lock(h);
|
||||
now = runtime·nanotime();
|
||||
if (trace)
|
||||
|
|
|
|||
Loading…
Reference in New Issue