]> Cypherpunks repositories - gostls13.git/commitdiff
Save the scheduling state even predawn.
authorIan Lance Taylor <iant@golang.org>
Fri, 7 May 2010 05:07:03 +0000 (22:07 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 7 May 2010 05:07:03 +0000 (22:07 -0700)
This permits cgo callbacks to work when run in init code.
Otherwise cgocallback switches to the wrong stack address.

R=rsc
CC=golang-dev
https://golang.org/cl/1123043

src/pkg/runtime/proc.c

index 0fef16aa6e5a0cdb0b9681b6a0fae424124db98b..a587a7fd43120ea2966368acd3ac8ecfdd5497cd 100644 (file)
@@ -551,15 +551,15 @@ void
 ·entersyscall(void)
 {
        lock(&sched);
+       // Leave SP around for gc and traceback.
+       // Do before notewakeup so that gc
+       // never sees Gsyscall with wrong stack.
+       gosave(&g->sched);
        if(sched.predawn) {
                unlock(&sched);
                return;
        }
        g->status = Gsyscall;
-       // Leave SP around for gc and traceback.
-       // Do before notewakeup so that gc
-       // never sees Gsyscall with wrong stack.
-       gosave(&g->sched);
        sched.mcpu--;
        sched.msyscall++;
        if(sched.gwait != 0)