diff options
author | Ian Lance Taylor <iant@golang.org> | 2015-12-21 22:27:01 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2015-12-24 17:00:04 +0000 |
commit | f7e51c132059a78953b768ca66e457b40985930e (patch) | |
tree | e83f12442cc839b5f2d80c14c3b7131666bc9746 /src/runtime/sys_openbsd_386.s | |
parent | e4dcf5c8c22d98ac9eac7b9b226596229624cb1d (diff) | |
download | go-f7e51c132059a78953b768ca66e457b40985930e.tar.gz go-f7e51c132059a78953b768ca66e457b40985930e.zip |
runtime: adjust gsignal stack to current signal stack
If non-Go code calls sigaltstack before a signal is received, use
sigaltstack to determine the current signal stack and set the gsignal
stack to use it. This makes the Go runtime more robust in the face of
non-Go code. We still can't handle a disabled signal stack or a signal
triggered with SA_ONSTACK clear, but we now give clear errors for those
cases.
Fixes #7227.
Update #9896.
Change-Id: Icb1607e01fd6461019b6d77d940e59b3aed4d258
Reviewed-on: https://go-review.googlesource.com/18102
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Diffstat (limited to 'src/runtime/sys_openbsd_386.s')
-rw-r--r-- | src/runtime/sys_openbsd_386.s | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/src/runtime/sys_openbsd_386.s b/src/runtime/sys_openbsd_386.s index bdf18d88f9..769b2f9455 100644 --- a/src/runtime/sys_openbsd_386.s +++ b/src/runtime/sys_openbsd_386.s @@ -195,44 +195,26 @@ TEXT runtime·sigprocmask(SB),NOSPLIT,$-4 MOVL AX, ret+8(FP) RET -TEXT runtime·sigtramp(SB),NOSPLIT,$44 - get_tls(CX) - - // check that g exists - MOVL g(CX), DI - CMPL DI, $0 - JNE 6(PC) - MOVL signo+0(FP), BX - MOVL BX, 0(SP) - MOVL $runtime·badsignal(SB), AX +TEXT runtime·sigfwd(SB),NOSPLIT,$12-16 + MOVL sig+4(FP), AX + MOVL AX, 0(SP) + MOVL info+8(FP), AX + MOVL AX, 4(SP) + MOVL ctx+12(FP), AX + MOVL AX, 8(SP) + MOVL fn+0(FP), AX CALL AX - JMP ret - - // save g - MOVL DI, 20(SP) - - // g = m->gsignal - MOVL g_m(DI), BX - MOVL m_gsignal(BX), BX - MOVL BX, g(CX) + RET - // copy arguments for call to sighandler +TEXT runtime·sigtramp(SB),NOSPLIT,$12 MOVL signo+0(FP), BX MOVL BX, 0(SP) MOVL info+4(FP), BX MOVL BX, 4(SP) MOVL context+8(FP), BX MOVL BX, 8(SP) - MOVL DI, 12(SP) - - CALL runtime·sighandler(SB) - - // restore g - get_tls(CX) - MOVL 20(SP), BX - MOVL BX, g(CX) + CALL runtime·sigtrampgo(SB) -ret: // call sigreturn MOVL context+8(FP), AX MOVL $0, 0(SP) // syscall gap |