1
0
mirror of https://github.com/golang/go synced 2024-11-17 21:04:43 -07:00

runtime: fix crash in badsignal()

The linker can generate split stack prolog when a textflag 7 function
makes an indirect function call.  If it happens, badsignal() crashes
trying to dereference g.
Fixes #5337.

R=bradfitz, dave, adg, iant, r, minux.ma
CC=adonovan, golang-dev
https://golang.org/cl/9226043
This commit is contained in:
Dmitriy Vyukov 2013-05-06 16:15:03 -07:00 committed by Ian Lance Taylor
parent b3b1efd882
commit f322c78692
5 changed files with 30 additions and 15 deletions

View File

@ -540,14 +540,17 @@ static int8 badsignal[] = "runtime: signal received on thread not created by Go:
void
runtime·badsignal(int32 sig)
{
int32 len;
if (sig == SIGPROF) {
return; // Ignore SIGPROFs intended for a non-Go thread.
}
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));
// Can't call findnull() because it will split stack.
for(len = 0; runtime·sigtab[sig].name[len]; len++)
;
runtime·write(2, runtime·sigtab[sig].name, len);
}
runtime·write(2, "\n", 1);
runtime·exit(1);

View File

@ -252,14 +252,17 @@ static int8 badsignal[] = "runtime: signal received on thread not created by Go:
void
runtime·badsignal(int32 sig)
{
int32 len;
if (sig == SIGPROF) {
return; // Ignore SIGPROFs intended for a non-Go thread.
}
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));
// Can't call findnull() because it will split stack.
for(len = 0; runtime·sigtab[sig].name[len]; len++)
;
runtime·write(2, runtime·sigtab[sig].name, len);
}
runtime·write(2, "\n", 1);
runtime·exit(1);

View File

@ -300,14 +300,17 @@ static int8 badsignal[] = "runtime: signal received on thread not created by Go:
void
runtime·badsignal(int32 sig)
{
int32 len;
if (sig == SIGPROF) {
return; // Ignore SIGPROFs intended for a non-Go thread.
}
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));
// Can't call findnull() because it will split stack.
for(len = 0; runtime·sigtab[sig].name[len]; len++)
;
runtime·write(2, runtime·sigtab[sig].name, len);
}
runtime·write(2, "\n", 1);
runtime·exit(1);

View File

@ -292,14 +292,17 @@ static int8 badsignal[] = "runtime: signal received on thread not created by Go:
void
runtime·badsignal(int32 sig)
{
int32 len;
if (sig == SIGPROF) {
return; // Ignore SIGPROFs intended for a non-Go thread.
}
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));
// Can't call findnull() because it will split stack.
for(len = 0; runtime·sigtab[sig].name[len]; len++)
;
runtime·write(2, runtime·sigtab[sig].name, len);
}
runtime·write(2, "\n", 1);
runtime·exit(1);

View File

@ -274,14 +274,17 @@ static int8 badsignal[] = "runtime: signal received on thread not created by Go:
void
runtime·badsignal(int32 sig)
{
int32 len;
if (sig == SIGPROF) {
return; // Ignore SIGPROFs intended for a non-Go thread.
}
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));
// Can't call findnull() because it will split stack.
for(len = 0; runtime·sigtab[sig].name[len]; len++)
;
runtime·write(2, runtime·sigtab[sig].name, len);
}
runtime·write(2, "\n", 1);
runtime·exit(1);