mirror of
https://github.com/golang/go
synced 2024-11-21 17:14:45 -07:00
runtime: print error on receipt of signal on non-Go thread
It's the best we can do before Go 1. For issue 3250; not a fix but at least less mysterious. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5797068
This commit is contained in:
parent
72801291d6
commit
b23691148f
@ -126,13 +126,18 @@ TEXT runtime·sigaction(SB),7,$0
|
||||
// 20(FP) context
|
||||
TEXT runtime·sigtramp(SB),7,$40
|
||||
get_tls(CX)
|
||||
|
||||
// check that m exists
|
||||
MOVL m(CX), BP
|
||||
CMPL BP, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVL g(CX), DI
|
||||
MOVL DI, 20(SP)
|
||||
|
||||
// g = m->gsignal
|
||||
MOVL m(CX), BP
|
||||
MOVL m_gsignal(BP), BP
|
||||
MOVL BP, g(CX)
|
||||
|
||||
|
@ -117,12 +117,17 @@ TEXT runtime·sigaction(SB),7,$0
|
||||
TEXT runtime·sigtramp(SB),7,$64
|
||||
get_tls(BX)
|
||||
|
||||
// check that m exists
|
||||
MOVQ m(BX), BP
|
||||
CMPQ BP, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVQ g(BX), R10
|
||||
MOVQ R10, 48(SP)
|
||||
|
||||
// g = m->gsignal
|
||||
MOVQ m(BX), BP
|
||||
MOVQ m_gsignal(BP), BP
|
||||
MOVQ BP, g(BX)
|
||||
|
||||
|
@ -159,12 +159,17 @@ TEXT runtime·sigaction(SB),7,$-4
|
||||
TEXT runtime·sigtramp(SB),7,$44
|
||||
get_tls(CX)
|
||||
|
||||
// check that m exists
|
||||
MOVL m(CX), BX
|
||||
CMPL BX, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVL g(CX), DI
|
||||
MOVL DI, 20(SP)
|
||||
|
||||
// g = m->gsignal
|
||||
MOVL m(CX), BX
|
||||
MOVL m_gsignal(BX), BX
|
||||
MOVL BX, g(CX)
|
||||
|
||||
|
@ -135,12 +135,17 @@ TEXT runtime·sigaction(SB),7,$-8
|
||||
TEXT runtime·sigtramp(SB),7,$64
|
||||
get_tls(BX)
|
||||
|
||||
// check that m exists
|
||||
MOVQ m(BX), BP
|
||||
CMPQ BP, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVQ g(BX), R10
|
||||
MOVQ R10, 40(SP)
|
||||
|
||||
// g = m->signal
|
||||
MOVQ m(BX), BP
|
||||
MOVQ m_gsignal(BP), BP
|
||||
MOVQ BP, g(BX)
|
||||
|
||||
|
@ -167,6 +167,12 @@ TEXT runtime·rt_sigaction(SB),7,$0
|
||||
TEXT runtime·sigtramp(SB),7,$44
|
||||
get_tls(CX)
|
||||
|
||||
// check that m exists
|
||||
MOVL m(CX), BX
|
||||
CMPL BX, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVL g(CX), DI
|
||||
MOVL DI, 20(SP)
|
||||
|
@ -154,12 +154,17 @@ TEXT runtime·rt_sigaction(SB),7,$0-32
|
||||
TEXT runtime·sigtramp(SB),7,$64
|
||||
get_tls(BX)
|
||||
|
||||
// check that m exists
|
||||
MOVQ m(BX), BP
|
||||
CMPQ BP, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVQ g(BX), R10
|
||||
MOVQ R10, 40(SP)
|
||||
|
||||
// g = m->gsignal
|
||||
MOVQ m(BX), BP
|
||||
MOVQ m_gsignal(BP), BP
|
||||
MOVQ BP, g(BX)
|
||||
|
||||
|
@ -138,12 +138,17 @@ TEXT runtime·sigaction(SB),7,$-4
|
||||
TEXT runtime·sigtramp(SB),7,$44
|
||||
get_tls(CX)
|
||||
|
||||
// check that m exists
|
||||
MOVL m(CX), BX
|
||||
CMPL BX, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVL g(CX), DI
|
||||
MOVL DI, 20(SP)
|
||||
|
||||
// g = m->gsignal
|
||||
MOVL m(CX), BX
|
||||
MOVL m_gsignal(BX), BX
|
||||
MOVL BX, g(CX)
|
||||
|
||||
|
@ -176,12 +176,17 @@ TEXT runtime·sigaction(SB),7,$-8
|
||||
TEXT runtime·sigtramp(SB),7,$64
|
||||
get_tls(BX)
|
||||
|
||||
// check that m exists
|
||||
MOVQ m(BX), BP
|
||||
CMPQ BP, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVQ g(BX), R10
|
||||
MOVQ R10, 40(SP)
|
||||
|
||||
// g = m->signal
|
||||
MOVQ m(BX), BP
|
||||
MOVQ m_gsignal(BP), BP
|
||||
MOVQ BP, g(BX)
|
||||
|
||||
|
@ -138,12 +138,17 @@ TEXT runtime·sigaction(SB),7,$-4
|
||||
TEXT runtime·sigtramp(SB),7,$44
|
||||
get_tls(CX)
|
||||
|
||||
// check that m exists
|
||||
MOVL m(CX), BX
|
||||
CMPL BX, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVL g(CX), DI
|
||||
MOVL DI, 20(SP)
|
||||
|
||||
// g = m->gsignal
|
||||
MOVL m(CX), BX
|
||||
MOVL m_gsignal(BX), BX
|
||||
MOVL BX, g(CX)
|
||||
|
||||
|
@ -176,12 +176,17 @@ TEXT runtime·sigaction(SB),7,$-8
|
||||
TEXT runtime·sigtramp(SB),7,$64
|
||||
get_tls(BX)
|
||||
|
||||
// check that m exists
|
||||
MOVQ m(BX), BP
|
||||
CMPQ BP, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
// save g
|
||||
MOVQ g(BX), R10
|
||||
MOVQ R10, 40(SP)
|
||||
|
||||
// g = m->signal
|
||||
MOVQ m(BX), BP
|
||||
MOVQ m_gsignal(BP), BP
|
||||
MOVQ BP, g(BX)
|
||||
|
||||
|
@ -58,6 +58,26 @@ TEXT runtime·badcallback(SB),7,$24
|
||||
MOVL BP, SI
|
||||
RET
|
||||
|
||||
TEXT runtime·badsignal(SB),7,$24
|
||||
// stderr
|
||||
MOVL $-12, 0(SP)
|
||||
MOVL SP, BP
|
||||
CALL *runtime·GetStdHandle(SB)
|
||||
MOVL BP, SP
|
||||
|
||||
MOVL AX, 0(SP) // handle
|
||||
MOVL $runtime·badsignalmsg(SB), DX // pointer
|
||||
MOVL DX, 4(SP)
|
||||
MOVL runtime·badsignallen(SB), DX // count
|
||||
MOVL DX, 8(SP)
|
||||
LEAL 20(SP), DX // written count
|
||||
MOVL $0, 0(DX)
|
||||
MOVL DX, 12(SP)
|
||||
MOVL $0, 16(SP) // overlapped
|
||||
CALL *runtime·WriteFile(SB)
|
||||
MOVL BP, SI
|
||||
RET
|
||||
|
||||
// faster get/set last error
|
||||
TEXT runtime·getlasterror(SB),7,$0
|
||||
MOVL 0x34(FS), AX
|
||||
@ -79,7 +99,15 @@ TEXT runtime·sigtramp(SB),7,$28
|
||||
MOVL CX, 0(SP)
|
||||
MOVL context+8(FP), CX
|
||||
MOVL CX, 4(SP)
|
||||
|
||||
get_tls(CX)
|
||||
|
||||
// check that m exists
|
||||
MOVL m(CX), AX
|
||||
CMPL AX, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
MOVL g(CX), CX
|
||||
MOVL CX, 8(SP)
|
||||
|
||||
|
@ -82,6 +82,28 @@ TEXT runtime·badcallback(SB),7,$48
|
||||
|
||||
RET
|
||||
|
||||
TEXT runtime·badsignal(SB),7,$48
|
||||
// stderr
|
||||
MOVQ $-12, CX // stderr
|
||||
MOVQ CX, 0(SP)
|
||||
MOVQ runtime·GetStdHandle(SB), AX
|
||||
CALL AX
|
||||
|
||||
MOVQ AX, CX // handle
|
||||
MOVQ CX, 0(SP)
|
||||
MOVQ $runtime·badsignalmsg(SB), DX // pointer
|
||||
MOVQ DX, 8(SP)
|
||||
MOVL $runtime·badsignallen(SB), R8 // count
|
||||
MOVQ R8, 16(SP)
|
||||
LEAQ 40(SP), R9 // written count
|
||||
MOVQ $0, 0(R9)
|
||||
MOVQ R9, 24(SP)
|
||||
MOVQ $0, 32(SP) // overlapped
|
||||
MOVQ runtime·WriteFile(SB), AX
|
||||
CALL AX
|
||||
|
||||
RET
|
||||
|
||||
// faster get/set last error
|
||||
TEXT runtime·getlasterror(SB),7,$0
|
||||
MOVQ 0x30(GS), AX
|
||||
@ -106,7 +128,15 @@ TEXT runtime·sigtramp(SB),7,$56
|
||||
// copy arguments for call to sighandler
|
||||
MOVQ CX, 0(SP)
|
||||
MOVQ R8, 8(SP)
|
||||
|
||||
get_tls(CX)
|
||||
|
||||
// check that m exists
|
||||
MOVQ m(BX), AX
|
||||
CMPQ AX, $0
|
||||
JNE 2(PC)
|
||||
CALL runtime·badsignal(SB)
|
||||
|
||||
MOVQ g(CX), CX
|
||||
MOVQ CX, 16(SP)
|
||||
|
||||
|
@ -487,3 +487,13 @@ runtime·badcallback(void)
|
||||
{
|
||||
runtime·write(2, badcallback, sizeof badcallback - 1);
|
||||
}
|
||||
|
||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||
|
||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
#pragma textflag 7
|
||||
void
|
||||
runtime·badsignal(void)
|
||||
{
|
||||
runtime·write(2, badsignal, sizeof badsignal - 1);
|
||||
}
|
||||
|
@ -205,3 +205,13 @@ runtime·badcallback(void)
|
||||
{
|
||||
runtime·write(2, badcallback, sizeof badcallback - 1);
|
||||
}
|
||||
|
||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||
|
||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
#pragma textflag 7
|
||||
void
|
||||
runtime·badsignal(void)
|
||||
{
|
||||
runtime·write(2, badsignal, sizeof badsignal - 1);
|
||||
}
|
||||
|
@ -265,3 +265,13 @@ runtime·badcallback(void)
|
||||
{
|
||||
runtime·write(2, badcallback, sizeof badcallback - 1);
|
||||
}
|
||||
|
||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||
|
||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
#pragma textflag 7
|
||||
void
|
||||
runtime·badsignal(void)
|
||||
{
|
||||
runtime·write(2, badsignal, sizeof badsignal - 1);
|
||||
}
|
||||
|
@ -223,3 +223,13 @@ runtime·badcallback(void)
|
||||
{
|
||||
runtime·write(2, badcallback, sizeof badcallback - 1);
|
||||
}
|
||||
|
||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||
|
||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
#pragma textflag 7
|
||||
void
|
||||
runtime·badsignal(void)
|
||||
{
|
||||
runtime·write(2, badsignal, sizeof badsignal - 1);
|
||||
}
|
||||
|
@ -223,3 +223,13 @@ runtime·badcallback(void)
|
||||
{
|
||||
runtime·write(2, badcallback, sizeof badcallback - 1);
|
||||
}
|
||||
|
||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||
|
||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
#pragma textflag 7
|
||||
void
|
||||
runtime·badsignal(void)
|
||||
{
|
||||
runtime·write(2, badsignal, sizeof badsignal - 1);
|
||||
}
|
||||
|
@ -257,3 +257,13 @@ runtime·badcallback(void)
|
||||
{
|
||||
runtime·pwrite(2, badcallback, sizeof badcallback - 1, -1LL);
|
||||
}
|
||||
|
||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||
|
||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
#pragma textflag 7
|
||||
void
|
||||
runtime·badsignal(void)
|
||||
{
|
||||
runtime·pwrite(2, badsignal, sizeof badsignal - 1, -1LL);
|
||||
}
|
||||
|
@ -425,3 +425,6 @@ runtime·setprof(bool on)
|
||||
|
||||
int8 runtime·badcallbackmsg[] = "runtime: cgo callback on thread not created by Go.\n";
|
||||
int32 runtime·badcallbacklen = sizeof runtime·badcallbackmsg - 1;
|
||||
|
||||
int8 runtime·badsignalmsg[] = "runtime: signal received on thread not created by Go.\n";
|
||||
int32 runtime·badsignallen = sizeof runtime·badsignalmsg - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user