]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix bug in preemption checks; was causing "lock count" panics
authorRuss Cox <rsc@golang.org>
Tue, 12 Jan 2010 18:03:02 +0000 (10:03 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 12 Jan 2010 18:03:02 +0000 (10:03 -0800)
R=r
CC=golang-dev
https://golang.org/cl/186078

src/pkg/runtime/malloc.cgo
src/pkg/runtime/proc.c

index 948257973e5706f70c43cf53e4d4f81cc7b16944..a85c39d83d3f8fe4895ec906b9f8e7ab7681fbe7 100644 (file)
@@ -27,7 +27,7 @@ mallocgc(uintptr size, uint32 refflag, int32 dogc)
        void *v;
        uint32 *ref;
 
-       if(gcwaiting && g != m->g0)
+       if(gcwaiting && g != m->g0 && m->locks == 0)
                gosched();
        if(m->mallocing)
                throw("malloc/free - deadlock");
index 6324b4be4cc4cc32e9bdc9285c6a9efca744bcc5..99fa26ad0b2ec1488cd06f394ed55b5941e4d9d6 100644 (file)
@@ -523,6 +523,8 @@ scheduler(void)
 void
 gosched(void)
 {
+       if(m->locks != 0)
+               throw("gosched holding locks");
        if(g == m->g0)
                throw("gosched of g0");
        if(gosave(&g->sched) == 0)