]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix scanning of not started goroutines
authorCarl Shapiro <cshapiro@google.com>
Thu, 16 May 2013 17:42:39 +0000 (10:42 -0700)
committerCarl Shapiro <cshapiro@google.com>
Thu, 16 May 2013 17:42:39 +0000 (10:42 -0700)
The stack scanner for not started goroutines ignored the arguments
area when its size was unknown.  With this change, the distance
between the stack pointer and the stack base will be used instead.

Fixes #5486

R=golang-dev, bradfitz, iant, dvyukov
CC=golang-dev
https://golang.org/cl/9440043

src/pkg/runtime/mgc0.c

index 2f26e31c3f45cbb2a41649a4f4e826303da1b8ec..11248772536e584c3174fce8f1a87e081448f2b6 100644 (file)
@@ -1454,11 +1454,18 @@ addstackroots(G *gp)
                        // be scanned.  No other live values should be on the
                        // stack.
                        f = runtime·findfunc((uintptr)gp->fnstart->fn);
-                       if(f->args > 0) {
+                       if(f->args != 0) {
                                if(thechar == '5')
                                        sp += sizeof(uintptr);
-                               addroot((Obj){sp, f->args, 0});
-                       }
+                               // If the size of the arguments is known
+                               // scan just the incoming arguments.
+                               // Otherwise, scan everything between the
+                               // top and the bottom of the stack.
+                               if(f->args > 0)
+                                       addroot((Obj){sp, f->args, 0});
+                               else
+                                       addroot((Obj){sp, (byte*)stk - sp, 0}); 
+                       } 
                        return;
                }
        }