diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-14 23:16:04 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-14 23:16:04 +0000 |
commit | cccf7f101ef0129f8494c0fe2f5d08f0cd5cea88 (patch) | |
tree | b5ec8e784225739b75eaacc89ac8e28611847abf /libgo | |
parent | 17515fad4880e3406bc2334b88700f800f93a1be (diff) | |
download | gcc-cccf7f101ef0129f8494c0fe2f5d08f0cd5cea88.tar.gz |
runtime: don't crash if signal handler info argument is nil
Apparently on Solaris 10 a SA_SIGINFO signal handler can be invoked with
a nil info argument. I would not have believed it but I've now seen it
happen, and the sigaction man page actually says "If the second argument
is not equal to NULL, it points to a siginfo_t structure...." So, if
that happens, don't crash.
Also fix another case where we want to make sure that &T{} does not
allocate.
Reviewed-on: https://go-review.googlesource.com/33150
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242403 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/runtime/signal_gccgo.go | 9 | ||||
-rw-r--r-- | libgo/go/runtime/signal_sigtramp.go | 3 | ||||
-rw-r--r-- | libgo/runtime/go-signal.c | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/libgo/go/runtime/signal_gccgo.go b/libgo/go/runtime/signal_gccgo.go index 0ecafccec4c..321c6197889 100644 --- a/libgo/go/runtime/signal_gccgo.go +++ b/libgo/go/runtime/signal_gccgo.go @@ -47,7 +47,14 @@ type sigctxt struct { ctxt unsafe.Pointer } -func (c *sigctxt) sigcode() uint64 { return uint64(c.info.si_code) } +func (c *sigctxt) sigcode() uint64 { + if c.info == nil { + // This can happen on Solaris 10. We don't know the + // code, just avoid a misleading value. + return _SI_USER + 1 + } + return uint64(c.info.si_code) +} //go:nosplit func sigblock() { diff --git a/libgo/go/runtime/signal_sigtramp.go b/libgo/go/runtime/signal_sigtramp.go index 67b9e670433..667d5feed98 100644 --- a/libgo/go/runtime/signal_sigtramp.go +++ b/libgo/go/runtime/signal_sigtramp.go @@ -29,7 +29,8 @@ func sigtrampgo(sig uint32, info *_siginfo_t, ctx unsafe.Pointer) { // get here anyhow. return } - badsignal(uintptr(sig), &sigctxt{info, ctx}) + c := sigctxt{info, ctx} + badsignal(uintptr(sig), &c) return } diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c index 9ee02a34f8f..b844dc59b7c 100644 --- a/libgo/runtime/go-signal.c +++ b/libgo/runtime/go-signal.c @@ -187,7 +187,11 @@ getSiginfo(siginfo_t *info, void *context __attribute__((unused))) Location loc[1]; int32 n; - ret.sigaddr = (uintptr)(info->si_addr); + if (info == nil) { + ret.sigaddr = 0; + } else { + ret.sigaddr = (uintptr)(info->si_addr); + } ret.sigpc = 0; // There doesn't seem to be a portable way to get the PC. |