1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:54:40 -07:00

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
This commit is contained in:
Russ Cox 2013-07-18 22:58:49 -04:00
parent b2b15d1230
commit df3e6ce4b1

View File

@ -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