github.com/MangoDowner/go-gm@v0.0.0-20180818020936-8baa2bd4408c/misc/cgo/testsanitizers/tsan10.go (about) 1 // Copyright 2017 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 package main 6 7 // This program hung when run under the C/C++ ThreadSanitizer. 8 // TSAN defers asynchronous signals until the signaled thread calls into libc. 9 // Since the Go runtime makes direct futex syscalls, Go runtime threads could 10 // run for an arbitrarily long time without triggering the libc interceptors. 11 // See https://golang.org/issue/18717. 12 13 import ( 14 "os" 15 "os/signal" 16 "syscall" 17 ) 18 19 /* 20 #cgo CFLAGS: -g -fsanitize=thread 21 #cgo LDFLAGS: -g -fsanitize=thread 22 */ 23 import "C" 24 25 func main() { 26 c := make(chan os.Signal, 1) 27 signal.Notify(c, syscall.SIGUSR1) 28 defer signal.Stop(c) 29 syscall.Kill(syscall.Getpid(), syscall.SIGUSR1) 30 <-c 31 }