From e5bd6e1c7944713c816cf94ae412a700c271cfca Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 18 Apr 2020 20:11:46 -0700 Subject: 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 TryBot-Result: Gobot Gobot Reviewed-by: Austin Clements --- src/runtime/testdata/testprogcgo/segv.go | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/runtime/testdata/testprogcgo/segv.go (limited to 'src/runtime/testdata') 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() +} -- cgit v1.3