]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix bad status throw
authorRuss Cox <rsc@golang.org>
Thu, 8 Apr 2010 20:24:53 +0000 (13:24 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 8 Apr 2010 20:24:53 +0000 (13:24 -0700)
when garbage collector sees recovering goroutine

Fixes #711.

R=r
CC=golang-dev
https://golang.org/cl/869045

src/pkg/runtime/mgc0.c
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h

index f61c10c60337391db9989c93f6a03e77c5cc68cc..5265bea21f15534612677ef2ee0a4bd78b2ff8ca 100644 (file)
@@ -135,6 +135,7 @@ mark(void)
                case Grunnable:
                case Gsyscall:
                case Gwaiting:
+               case Grecovery:
                        scanstack(gp);
                        break;
                }
index 454a4a2175bd4b0505d357981b53f878acc1af62..1a1895dcb44640b4edb335920863d28fef87ee27 100644 (file)
@@ -461,9 +461,7 @@ scheduler(void)
                        
                        // unwind to the stack frame with d->sp in it.
                        unwindstack(gp, d->sp);
-                       if(d->sp < gp->stackguard || gp->stackbase < d->sp)
-                               throw("bad stack in recovery");
-                       
+
                        // make the deferproc for this d return again,
                        // this time returning 1.  function will jump to
                        // standard return epilogue.
@@ -930,6 +928,11 @@ unwindstack(G *gp, byte *sp)
                gp->stackguard = top->stackguard;
                free(stk);
        }
+
+       if(sp != nil && (sp < gp->stackguard - StackGuard || gp->stackbase < sp)) {
+               printf("recover: %p not in [%p, %p]\n", sp, gp->stackguard - StackGuard, gp->stackbase);
+               throw("bad unwindstack");
+       }
 }
 
 static void
index e2aedb4ceec8635a4dd822fff2e1878a0ea0c424..26ce4b635cf79b7bf8fd2e09e6e41d308376d7c5 100644 (file)
@@ -92,6 +92,10 @@ extern       register        M*      m;
 enum
 {
        // G status
+       //
+       // If you add to this list, add to the list
+       // of "okay during garbage collection" status
+       // in mgc0.c too.
        Gidle,
        Grunnable,
        Grunning,