From: Dmitriy Vyukov Date: Mon, 25 Jun 2012 07:08:09 +0000 (+0400) Subject: runtime: fix potential GC deadlock X-Git-Tag: go1.1rc2~2893 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=902911bcff91127cd8c5c7e10d200eb97f0c1893;p=gostls13.git runtime: fix potential GC deadlock The issue seems to not be triggered right now, but I've seen the deadlock after some other legal modifications to runtime. So I think we are safer this way. R=rsc, r CC=golang-dev https://golang.org/cl/6339051 --- diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c index 5f1bff2c46..70d0a0f2e2 100644 --- a/src/pkg/runtime/mgc0.c +++ b/src/pkg/runtime/mgc0.c @@ -905,12 +905,14 @@ runtime·gc(int32 force) work.debugmarkdone = 0; work.nproc = runtime·gcprocs(); addroots(); + m->locks++; // disable gc during mallocs in parforalloc if(work.markfor == nil) work.markfor = runtime·parforalloc(MaxGcproc); runtime·parforsetup(work.markfor, work.nproc, work.nroot, nil, false, markroot); if(work.sweepfor == nil) work.sweepfor = runtime·parforalloc(MaxGcproc); runtime·parforsetup(work.sweepfor, work.nproc, runtime·mheap.nspan, nil, true, sweepspan); + m->locks--; if(work.nproc > 1) { runtime·noteclear(&work.alldone); runtime·helpgc(work.nproc);