tsan10.go 798 B

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