diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-04-18 20:11:46 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-04-22 00:01:14 +0000 |
commit | e5bd6e1c7944713c816cf94ae412a700c271cfca (patch) | |
tree | 2fd972e8b6e0e72379e5a6adc626e034416efa9d /src/runtime/testdata | |
parent | 5a75f7c0b0789fe04ea4879a524cc95dbe734636 (diff) | |
download | go-e5bd6e1c7944713c816cf94ae412a700c271cfca.tar.gz go-e5bd6e1c7944713c816cf94ae412a700c271cfca.zip |
runtime: crash on SI_USER SigPanic signal
Clean up the code a little bit to make it clearer:
Don't check throwsplit for a SI_USER signal.
If throwsplit is set for a SigPanic signal, always throw;
discard any other flags.
Fixes #36420
Change-Id: Ic9dcd1108603d241f71c040504dfdc6e528f9767
Reviewed-on: https://go-review.googlesource.com/c/go/+/228900
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r-- | src/runtime/testdata/testprogcgo/segv.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprogcgo/segv.go b/src/runtime/testdata/testprogcgo/segv.go new file mode 100644 index 0000000000..77e75f276a --- /dev/null +++ b/src/runtime/testdata/testprogcgo/segv.go @@ -0,0 +1,60 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !plan9,!windows + +package main + +// static void nop() {} +import "C" + +import ( + "sync" + "syscall" +) + +func init() { + register("Segv", Segv) + register("SegvInCgo", SegvInCgo) +} + +var Sum int + +func Segv() { + c := make(chan bool) + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + close(c) + for i := 0; i < 10000; i++ { + Sum += i + } + }() + + <-c + + syscall.Kill(syscall.Getpid(), syscall.SIGSEGV) + + wg.Wait() +} + +func SegvInCgo() { + c := make(chan bool) + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + close(c) + for i := 0; i < 10000; i++ { + C.nop() + } + }() + + <-c + + syscall.Kill(syscall.Getpid(), syscall.SIGSEGV) + + wg.Wait() +} |