]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix runtime.sigreturn_tramp for NetBSD/ARM
authorShenghou Ma <minux.ma@gmail.com>
Tue, 2 Jul 2013 16:33:38 +0000 (00:33 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Tue, 2 Jul 2013 16:33:38 +0000 (00:33 +0800)
using m->tls[0] to save ucontext pointer is not re-entry safe, and
the old code didn't set it before the early return when signal is
received on non-Go threads.

so misc/cgo/test used to hang when testing issue 5337.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/10076045

src/pkg/runtime/sys_netbsd_arm.s

index 2d8c3d65687c53086fcd90a5593e3df20acfe832..0109ad8ca9bbed696b756655f698ec34e5d09ef7 100644 (file)
@@ -174,9 +174,9 @@ TEXT runtime·sigprocmask(SB),7,$0
        RET
 
 TEXT runtime·sigreturn_tramp(SB),7,$-4
-       // in runtime·sigtramp, we saved ucontext into m->tls[0],
-       // here we just load it and call sys_setcontext
-       MOVW m_tls(m), R0
+       // on entry, SP points to siginfo, we add sizeof(ucontext)
+       // to SP to get a pointer to ucontext.
+       ADD $0x80, R13, R0 // 0x80 == sizeof(UcontextT)
        SWI $0xa00134   // sys_setcontext
        // something failed, we have to exit
        MOVW $0x4242, R0 // magic return number
@@ -223,9 +223,6 @@ TEXT runtime·sigtramp(SB),7,$24
        MOVW R1, 8(R13) // info
        MOVW R2, 12(R13) // context
        MOVW R4, 16(R13) // gp
-       // we also save the ucontext into m->tls[0] for easy
-       // signal return
-       MOVW R2, m_tls(m)
 
        BL runtime·sighandler(SB)