runtime: in doscanstackswitch, set gp->m before gogo
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 7 Jan 2019 22:07:26 +0000 (22:07 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 7 Jan 2019 22:07:26 +0000 (22:07 +0000)
    This is following CL 156038. doscanstackswitch uses the same
    mechanism of switching goroutines as getTraceback, and so has
    the same problem as described in issue golang/go#29448. This CL
    applies the same fix.

    Reviewed-on: https://go-review.googlesource.com/c/156697

From-SVN: r267661

gcc/go/gofrontend/MERGE
libgo/runtime/proc.c

index 7c7370a5954af1a1868994ef4c3286f167743e24..267c32b4fd08e24c8e3e4180836e4fd213a45463 100644 (file)
@@ -1,4 +1,4 @@
-c8a9bccbc524381d150c84907a61ac257c1b07cc
+085ef4556ec810a5a9c422e7b86d98441dc92e86
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 4004df48612d6e1f5f4e12fac161b7855e54326b..1569b5bb898c189aa95271d52ba3dbbdff83fbf1 100644 (file)
@@ -482,9 +482,14 @@ void doscanstackswitch(G*, G*) __asm__(GOSYM_PREFIX "runtime.doscanstackswitch")
 void
 doscanstackswitch(G* me, G* gp)
 {
 void
 doscanstackswitch(G* me, G* gp)
 {
+       M* holdm;
+
        __go_assert(me->entry == nil);
        me->fromgogo = false;
 
        __go_assert(me->entry == nil);
        me->fromgogo = false;
 
+       holdm = gp->m;
+       gp->m = me->m;
+
 #ifdef USING_SPLIT_STACK
        __splitstack_getcontext((void*)(&me->stackcontext[0]));
 #endif
 #ifdef USING_SPLIT_STACK
        __splitstack_getcontext((void*)(&me->stackcontext[0]));
 #endif
@@ -507,6 +512,8 @@ doscanstackswitch(G* me, G* gp)
 
        if (gp->scang != 0)
                runtime_gogo(gp);
 
        if (gp->scang != 0)
                runtime_gogo(gp);
+
+       gp->m = holdm;
 }
 
 // Do a stack scan, then switch back to the g that triggers this scan.
 }
 
 // Do a stack scan, then switch back to the g that triggers this scan.
@@ -515,21 +522,15 @@ static void
 gscanstack(G *gp)
 {
        G *oldg, *oldcurg;
 gscanstack(G *gp)
 {
        G *oldg, *oldcurg;
-       M* holdm;
 
        oldg = (G*)gp->scang;
        oldcurg = oldg->m->curg;
 
        oldg = (G*)gp->scang;
        oldcurg = oldg->m->curg;
-       holdm = gp->m;
-       if(holdm != nil && holdm != g->m)
-               runtime_throw("gscanstack: m is not nil");
        oldg->m->curg = gp;
        oldg->m->curg = gp;
-       gp->m = oldg->m;
        gp->scang = 0;
 
        doscanstack(gp, (void*)gp->scangcw);
 
        gp->scangcw = 0;
        gp->scang = 0;
 
        doscanstack(gp, (void*)gp->scangcw);
 
        gp->scangcw = 0;
-       gp->m = holdm;
        oldg->m->curg = oldcurg;
        runtime_gogo(oldg);
 }
        oldg->m->curg = oldcurg;
        runtime_gogo(oldg);
 }