PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / misc / cgo / testsanitizers / src / tsan12.go
blob3e767eee1f83e080d75d53d65082939809240cbe
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.
5 package main
7 // This program hung when run under the C/C++ ThreadSanitizer. TSAN installs a
8 // libc interceptor that writes signal handlers to a global variable within the
9 // TSAN runtime instead of making a sigaction system call. A bug in
10 // syscall.runtime_AfterForkInChild corrupted TSAN's signal forwarding table
11 // during calls to (*os/exec.Cmd).Run, causing the parent process to fail to
12 // invoke signal handlers.
14 import (
15 "fmt"
16 "os"
17 "os/exec"
18 "os/signal"
19 "syscall"
22 import "C"
24 func main() {
25 ch := make(chan os.Signal)
26 signal.Notify(ch, syscall.SIGUSR1)
28 if err := exec.Command("true").Run(); err != nil {
29 fmt.Fprintf(os.Stderr, "Unexpected error from `true`: %v", err)
30 os.Exit(1)
33 syscall.Kill(syscall.Getpid(), syscall.SIGUSR1)
34 <-ch