mirror of
https://github.com/golang/go
synced 2024-11-21 18:24:46 -07:00
runtime: fix 386 signal handler bug
Cannot assume that g == m->curg at time of signal. Must save actual g and restore. Fixes flaky crashes with messages like throw: malloc mlookup throw: malloc/free - deadlock throw: unwindstack on self throw: free mlookup (and probably others) when running cgo. R=iant CC=golang-dev https://golang.org/cl/1648043
This commit is contained in:
parent
9d72aaabda
commit
53a529ab2b
@ -74,8 +74,13 @@ TEXT sigaction(SB),7,$0
|
|||||||
// 16(FP) siginfo
|
// 16(FP) siginfo
|
||||||
// 20(FP) context
|
// 20(FP) context
|
||||||
TEXT sigtramp(SB),7,$40
|
TEXT sigtramp(SB),7,$40
|
||||||
// g = m->gsignal
|
|
||||||
get_tls(CX)
|
get_tls(CX)
|
||||||
|
|
||||||
|
// save g
|
||||||
|
MOVL g(CX), BP
|
||||||
|
MOVL BP, 20(SP)
|
||||||
|
|
||||||
|
// g = m->gsignal
|
||||||
MOVL m(CX), BP
|
MOVL m(CX), BP
|
||||||
MOVL m_gsignal(BP), BP
|
MOVL m_gsignal(BP), BP
|
||||||
MOVL BP, g(CX)
|
MOVL BP, g(CX)
|
||||||
@ -91,10 +96,9 @@ TEXT sigtramp(SB),7,$40
|
|||||||
MOVL CX, 8(SP)
|
MOVL CX, 8(SP)
|
||||||
CALL DI
|
CALL DI
|
||||||
|
|
||||||
// g = m->curg
|
// restore g
|
||||||
get_tls(CX)
|
get_tls(CX)
|
||||||
MOVL m(CX), BP
|
MOVL 20(SP), BP
|
||||||
MOVL m_curg(BP), BP
|
|
||||||
MOVL BP, g(CX)
|
MOVL BP, g(CX)
|
||||||
|
|
||||||
MOVL context+16(FP), CX
|
MOVL context+16(FP), CX
|
||||||
|
@ -56,22 +56,39 @@ TEXT rt_sigaction(SB),7,$0
|
|||||||
INT $0x80
|
INT $0x80
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT sigtramp(SB),7,$0
|
TEXT sigtramp(SB),7,$40
|
||||||
get_tls(CX)
|
get_tls(CX)
|
||||||
MOVL m(CX), BP
|
|
||||||
MOVL m_gsignal(BP), AX
|
// save g
|
||||||
MOVL AX, g(CX)
|
MOVL g(CX), BX
|
||||||
JMP sighandler(SB)
|
MOVL BX, 20(SP)
|
||||||
|
|
||||||
|
// g = m->gsignal
|
||||||
|
MOVL m(CX), BX
|
||||||
|
MOVL m_gsignal(BX), BX
|
||||||
|
MOVL BX, g(CX)
|
||||||
|
|
||||||
|
// copy arguments for call to sighandler
|
||||||
|
MOVL sig+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)
|
||||||
|
|
||||||
|
CALL sighandler(SB)
|
||||||
|
|
||||||
|
// restore g
|
||||||
|
get_tls(CX)
|
||||||
|
MOVL 20(SP), BX
|
||||||
|
MOVL BX, g(CX)
|
||||||
|
|
||||||
|
RET
|
||||||
|
|
||||||
TEXT sigignore(SB),7,$0
|
TEXT sigignore(SB),7,$0
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT sigreturn(SB),7,$0
|
TEXT sigreturn(SB),7,$0
|
||||||
// g = m->curg
|
|
||||||
get_tls(CX)
|
|
||||||
MOVL m(CX), BP
|
|
||||||
MOVL m_curg(BP), BP
|
|
||||||
MOVL BP, g(CX)
|
|
||||||
MOVL $173, AX // rt_sigreturn
|
MOVL $173, AX // rt_sigreturn
|
||||||
INT $0x80
|
INT $0x80
|
||||||
INT $3 // not reached
|
INT $3 // not reached
|
||||||
@ -259,4 +276,3 @@ TEXT setldt(SB),7,$32
|
|||||||
MOVW AX, GS
|
MOVW AX, GS
|
||||||
|
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user