Debian Codegraph @

src/runtime/testdata/testprog/segv.go

raw
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build unix
6
7 package main
8
9 import "syscall"
10
11 func init() {
12 register("Segv", Segv)
13 }
14
15 var Sum int
16
17 func Segv() {
18 c := make(chan bool)
19 go func() {
20 close(c)
21 for i := 0; ; i++ {
22 Sum += i
23 }
24 }()
25
26 <-c
27
28 syscall.Kill(syscall.Getpid(), syscall.SIGSEGV)
29
30 // Wait for the OS to deliver the signal.
31 select {}
32 }