]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix bad g status after copystack
authorDmitriy Vyukov <dvyukov@google.com>
Thu, 6 Mar 2014 17:33:19 +0000 (21:33 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Thu, 6 Mar 2014 17:33:19 +0000 (21:33 +0400)
LGTM=khr
R=khr
CC=golang-codereviews, rsc
https://golang.org/cl/69870054

src/pkg/runtime/proc.c
src/pkg/runtime/stack.c

index 6a65e590ded4a88437b6ccab42ff9f28e6fc22d1..fdcbca4c32cdacc495dc93331b23a6fb942d71ae 100644 (file)
@@ -1364,6 +1364,8 @@ top:
 void
 runtime·park(bool(*unlockf)(G*, void*), void *lock, int8 *reason)
 {
+       if(g->status != Grunning)
+               runtime·throw("bad g status");
        m->waitlock = lock;
        m->waitunlockf = unlockf;
        g->waitreason = reason;
@@ -1415,6 +1417,8 @@ park0(G *gp)
 void
 runtime·gosched(void)
 {
+       if(g->status != Grunning)
+               runtime·throw("bad g status");
        runtime·mcall(runtime·gosched0);
 }
 
@@ -1443,6 +1447,8 @@ runtime·gosched0(G *gp)
 void
 runtime·goexit(void)
 {
+       if(g->status != Grunning)
+               runtime·throw("bad g status");
        if(raceenabled)
                runtime·racegoend();
        runtime·mcall(goexit0);
index 85885e80f9c80dbd50556d1d851739711c5ea5e6..e3daed5f285561bd3f8dd44d92799c6cf4afc7a9 100644 (file)
@@ -640,6 +640,7 @@ runtime·newstack(void)
                        copystack(gp, nframes, newsize);
                        if(StackDebug >= 1)
                                runtime·printf("stack grow done\n");
+                       gp->status = oldstatus;
                        runtime·gogo(&gp->sched);
                }
                // TODO: if stack is uncopyable because we're in C code, patch return value at