From: Russ Cox Date: Fri, 19 Jul 2013 02:58:49 +0000 (-0400) Subject: runtime: disable preemption during runtime.settype X-Git-Tag: go1.2rc2~999 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=df3e6ce4b1df508624082d31abb24300f9057b86;p=gostls13.git runtime: disable preemption during runtime.settype It assumes that the m will not change, and the m may change if the goroutine is preempted. R=golang-dev, r CC=golang-dev https://golang.org/cl/11560043 --- diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 78535c61f0..24ead24c41 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -672,6 +672,7 @@ runtime·settype(void *v, uintptr t) runtime·throw("settype: zero type"); mp = m; + m->locks++; buf = mp->settype_buf; i = mp->settype_bufsize; buf[i+0] = (uintptr)v; @@ -687,6 +688,10 @@ runtime·settype(void *v, uintptr t) s = runtime·MHeap_Lookup(&runtime·mheap, v); *(uintptr*)((uintptr)v+s->elemsize-sizeof(uintptr)) = t; } + + m->locks--; + if(m->locks == 0 && g->preempt) // restore the preemption request in case we've cleared it in newstack + g->stackguard0 = StackPreempt; } void