aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-04-22 16:03:30 -0700
committerIan Lance Taylor <iant@golang.org>2020-04-24 22:23:04 +0000
commit1cc46d3a255ee0ecbb2b602095e6e4ec4d22fd61 (patch)
treee3c8ccc42ff8ed7a8c424f82046ed8a52cf99444 /src/runtime/testdata
parentc53d1236dfaa900387519810c8de1a9353c55bab (diff)
downloadgo-1cc46d3a255ee0ecbb2b602095e6e4ec4d22fd61.tar.gz
go-1cc46d3a255ee0ecbb2b602095e6e4ec4d22fd61.zip
runtime: sleep in TestSegv program to let signal be delivered
Since we're sleeping rather than waiting for the goroutines, let the goroutines run forever. Fixes #38595 Change-Id: I4cd611fd7565f6e8d91e50c9273d91c514825314 Reviewed-on: https://go-review.googlesource.com/c/go/+/229484 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r--src/runtime/testdata/testprogcgo/segv.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/runtime/testdata/testprogcgo/segv.go b/src/runtime/testdata/testprogcgo/segv.go
index 77e75f276a..3237a8c69c 100644
--- a/src/runtime/testdata/testprogcgo/segv.go
+++ b/src/runtime/testdata/testprogcgo/segv.go
@@ -10,8 +10,8 @@ package main
import "C"
import (
- "sync"
"syscall"
+ "time"
)
func init() {
@@ -23,12 +23,9 @@ 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++ {
+ for i := 0; ; i++ {
Sum += i
}
}()
@@ -37,17 +34,15 @@ func Segv() {
syscall.Kill(syscall.Getpid(), syscall.SIGSEGV)
- wg.Wait()
+ // Give the OS time to deliver the signal.
+ time.Sleep(time.Second)
}
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++ {
+ for {
C.nop()
}
}()
@@ -56,5 +51,6 @@ func SegvInCgo() {
syscall.Kill(syscall.Getpid(), syscall.SIGSEGV)
- wg.Wait()
+ // Give the OS time to deliver the signal.
+ time.Sleep(time.Second)
}