aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-01-12 10:03:02 -0800
committerRuss Cox <rsc@golang.org>2010-01-12 10:03:02 -0800
commit711088106e74e909f78a8139bd46501f39d13e7d (patch)
treeccb9b550b77db81d9e148342b029c8f003ae111b
parent9d4d7d8f991ad3b27f223a2a987f2517971cd868 (diff)
downloadgo-711088106e74e909f78a8139bd46501f39d13e7d.tar.gz
go-711088106e74e909f78a8139bd46501f39d13e7d.zip
runtime: fix bug in preemption checks; was causing "lock count" panics
R=r CC=golang-dev https://golang.org/cl/186078
-rw-r--r--src/pkg/runtime/malloc.cgo2
-rw-r--r--src/pkg/runtime/proc.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/pkg/runtime/malloc.cgo b/src/pkg/runtime/malloc.cgo
index 948257973e..a85c39d83d 100644
--- a/src/pkg/runtime/malloc.cgo
+++ b/src/pkg/runtime/malloc.cgo
@@ -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");
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 6324b4be4c..99fa26ad0b 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -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)