1 // Copyright 2013 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.
5 // Only works on systems with syscall.Close.
6 // We need a fast system call to provoke the race,
7 // and Close(-1) is nearly universally fast.
9 // +build aix darwin dragonfly freebsd linux netbsd openbsd plan9
21 func TestGoroutineProfile(t
*testing
.T
) {
22 // GoroutineProfile used to use the wrong starting sp for
23 // goroutines coming out of system calls, causing possible
25 defer runtime
.GOMAXPROCS(runtime
.GOMAXPROCS(100))
28 defer atomic
.StoreUint32(&stop
, 1) // in case of panic
31 for i
:= 0; i
< 4; i
++ {
34 for atomic
.LoadUint32(&stop
) == 0 {
45 stk
:= make([]runtime
.StackRecord
, 128)
46 for n
:= 0; n
< max
; n
++ {
47 _
, ok
:= runtime
.GoroutineProfile(stk
)
49 t
.Fatalf("GoroutineProfile failed")
53 // If the program didn't crash, we passed.
54 atomic
.StoreUint32(&stop
, 1)