From e55517259217b29383d1a77e3c70e5cd19fa778b Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Wed, 3 Jul 2013 00:33:38 +0800 Subject: [PATCH] runtime: fix runtime.sigreturn_tramp for NetBSD/ARM 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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pkg/runtime/sys_netbsd_arm.s b/src/pkg/runtime/sys_netbsd_arm.s index 2d8c3d6568..0109ad8ca9 100644 --- a/src/pkg/runtime/sys_netbsd_arm.s +++ b/src/pkg/runtime/sys_netbsd_arm.s @@ -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)