From e84d9e1fb3a0d87abd60d31afb9cd0ddfb7d9bfa Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Mon, 29 Jul 2013 22:22:34 +0400 Subject: 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 --- src/pkg/runtime/stack.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/pkg/runtime/stack.c') diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c index dda65f9463..b959eb316d 100644 --- a/src/pkg/runtime/stack.c +++ b/src/pkg/runtime/stack.c @@ -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) { -- cgit v1.3