Commit e49f9456 authored by Alan Donovan's avatar Alan Donovan Committed by Russ Cox

runtime: expand error for signal received on non-Go thread.

We call runtime.findnull dynamically to avoid exceeding the
static nosplit stack limit check.  (Thanks minux!)

Fixes #4048.

R=rsc, minux.ma, ality
CC=golang-dev
https://golang.org/cl/7232066
parent c5b4292e
...@@ -497,7 +497,7 @@ runtime·badcallback(void) ...@@ -497,7 +497,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1); runtime·write(2, badcallback, sizeof badcallback - 1);
} }
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n"; static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split. // This runs on a foreign stack, without an m or a g. No stack split.
#pragma textflag 7 #pragma textflag 7
...@@ -508,5 +508,11 @@ runtime·badsignal(int32 sig) ...@@ -508,5 +508,11 @@ runtime·badsignal(int32 sig)
return; // Ignore SIGPROFs intended for a non-Go thread. return; // Ignore SIGPROFs intended for a non-Go thread.
} }
runtime·write(2, badsignal, sizeof badsignal - 1); runtime·write(2, badsignal, sizeof badsignal - 1);
if (0 <= sig && sig < NSIG) {
// Call runtime·findnull dynamically to circumvent static stack size check.
static int32 (*findnull)(byte*) = runtime·findnull;
runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runtime·sigtab[sig].name));
}
runtime·write(2, "\n", 1);
runtime·exit(1); runtime·exit(1);
} }
...@@ -206,7 +206,7 @@ runtime·badcallback(void) ...@@ -206,7 +206,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1); runtime·write(2, badcallback, sizeof badcallback - 1);
} }
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n"; static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split. // This runs on a foreign stack, without an m or a g. No stack split.
#pragma textflag 7 #pragma textflag 7
...@@ -217,5 +217,11 @@ runtime·badsignal(int32 sig) ...@@ -217,5 +217,11 @@ runtime·badsignal(int32 sig)
return; // Ignore SIGPROFs intended for a non-Go thread. return; // Ignore SIGPROFs intended for a non-Go thread.
} }
runtime·write(2, badsignal, sizeof badsignal - 1); runtime·write(2, badsignal, sizeof badsignal - 1);
if (0 <= sig && sig < NSIG) {
// Call runtime·findnull dynamically to circumvent static stack size check.
static int32 (*findnull)(byte*) = runtime·findnull;
runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runtime·sigtab[sig].name));
}
runtime·write(2, "\n", 1);
runtime·exit(1); runtime·exit(1);
} }
...@@ -256,7 +256,7 @@ runtime·badcallback(void) ...@@ -256,7 +256,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1); runtime·write(2, badcallback, sizeof badcallback - 1);
} }
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n"; static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split. // This runs on a foreign stack, without an m or a g. No stack split.
#pragma textflag 7 #pragma textflag 7
...@@ -267,5 +267,11 @@ runtime·badsignal(int32 sig) ...@@ -267,5 +267,11 @@ runtime·badsignal(int32 sig)
return; // Ignore SIGPROFs intended for a non-Go thread. return; // Ignore SIGPROFs intended for a non-Go thread.
} }
runtime·write(2, badsignal, sizeof badsignal - 1); runtime·write(2, badsignal, sizeof badsignal - 1);
if (0 <= sig && sig < NSIG) {
// Call runtime·findnull dynamically to circumvent static stack size check.
static int32 (*findnull)(byte*) = runtime·findnull;
runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runtime·sigtab[sig].name));
}
runtime·write(2, "\n", 1);
runtime·exit(1); runtime·exit(1);
} }
...@@ -252,7 +252,7 @@ runtime·badcallback(void) ...@@ -252,7 +252,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1); runtime·write(2, badcallback, sizeof badcallback - 1);
} }
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n"; static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split. // This runs on a foreign stack, without an m or a g. No stack split.
#pragma textflag 7 #pragma textflag 7
...@@ -263,5 +263,11 @@ runtime·badsignal(int32 sig) ...@@ -263,5 +263,11 @@ runtime·badsignal(int32 sig)
return; // Ignore SIGPROFs intended for a non-Go thread. return; // Ignore SIGPROFs intended for a non-Go thread.
} }
runtime·write(2, badsignal, sizeof badsignal - 1); runtime·write(2, badsignal, sizeof badsignal - 1);
if (0 <= sig && sig < NSIG) {
// Call runtime·findnull dynamically to circumvent static stack size check.
static int32 (*findnull)(byte*) = runtime·findnull;
runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runtime·sigtab[sig].name));
}
runtime·write(2, "\n", 1);
runtime·exit(1); runtime·exit(1);
} }
...@@ -229,7 +229,7 @@ runtime·badcallback(void) ...@@ -229,7 +229,7 @@ runtime·badcallback(void)
runtime·write(2, badcallback, sizeof badcallback - 1); runtime·write(2, badcallback, sizeof badcallback - 1);
} }
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n"; static int8 badsignal[] = "runtime: signal received on thread not created by Go: ";
// This runs on a foreign stack, without an m or a g. No stack split. // This runs on a foreign stack, without an m or a g. No stack split.
#pragma textflag 7 #pragma textflag 7
...@@ -240,5 +240,11 @@ runtime·badsignal(int32 sig) ...@@ -240,5 +240,11 @@ runtime·badsignal(int32 sig)
return; // Ignore SIGPROFs intended for a non-Go thread. return; // Ignore SIGPROFs intended for a non-Go thread.
} }
runtime·write(2, badsignal, sizeof badsignal - 1); runtime·write(2, badsignal, sizeof badsignal - 1);
if (0 <= sig && sig < NSIG) {
// Call runtime·findnull dynamically to circumvent static stack size check.
static int32 (*findnull)(byte*) = runtime·findnull;
runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runtime·sigtab[sig].name));
}
runtime·write(2, "\n", 1);
runtime·exit(1); runtime·exit(1);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment