]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/asm_386.s
[dev.power64] all: merge default (dd5014ed9b01) into dev.power64
[gostls13.git] / src / runtime / asm_386.s
index d0b3969bda9dc05c9c0421a290bb749b1445b6f9..2d102b27358b618c46ed3a320d61587313234eb2 100644 (file)
@@ -732,6 +732,20 @@ needm:
        MOVL    g(CX), BP
        MOVL    g_m(BP), BP
 
+       // Set m->sched.sp = SP, so that if a panic happens
+       // during the function we are about to execute, it will
+       // have a valid SP to run on the g0 stack.
+       // The next few lines (after the havem label)
+       // will save this SP onto the stack and then write
+       // the same SP back to m->sched.sp. That seems redundant,
+       // but if an unrecovered panic happens, unwindm will
+       // restore the g->sched.sp from the stack location
+       // and then onM will try to use it. If we don't set it here,
+       // that restored SP will be uninitialized (typically 0) and
+       // will not be usable.
+       MOVL    m_g0(BP), SI
+       MOVL    SP, (g_sched+gobuf_sp)(SI)
+
 havem:
        // Now there's a valid m, and we're running on its m->g0.
        // Save current m->g0->sched.sp on stack and then set it to SP.