runtime: do not split stacks in syscall status

Split stack checks (morestack) corrupt g->sched,
but g->sched must be preserved consistent for GC/traceback.
The change implements runtime.notetsleepg function,
which does entersyscall/exitsyscall and is carefully arranged
to not call any split functions in between.

R=rsc
CC=golang-dev
https://golang.org/cl/11575044
This commit is contained in:
Dmitriy Vyukov 2013-07-29 22:22:34 +04:00
parent b8734748b6
commit e84d9e1fb3
17 changed files with 290 additions and 185 deletions

View file

@ -246,6 +246,8 @@ runtime·newstack(void)
runtime·throw("runtime: preempt g0");
if(oldstatus == Grunning && m->p == nil)
runtime·throw("runtime: g is running but p is not");
if(oldstatus == Gsyscall && m->locks == 0)
runtime·throw("runtime: stack split during syscall");
// Be conservative about where we preempt.
// We are interested in preempting user Go code, not runtime code.
if(oldstatus != Grunning || m->locks || m->mallocing || m->gcing || m->p->status != Prunning) {