]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, syscall: use go:norace comment for forkAndExecInChild
authorIan Lance Taylor <iant@golang.org>
Tue, 20 Oct 2015 00:01:37 +0000 (17:01 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 20 Oct 2015 14:10:24 +0000 (14:10 +0000)
Use a go:norace comment rather than having the compiler know the special
name syscall.forkAndExecInChild.

Change-Id: I69bc6aa6fc40feb2148d23f269ff32453696fb28
Reviewed-on: https://go-review.googlesource.com/16097
Reviewed-by: Minux Ma <minux@golang.org>
src/cmd/compile/internal/gc/racewalk.go
src/syscall/exec_bsd.go
src/syscall/exec_linux.go
src/syscall/exec_plan9.go
src/syscall/exec_solaris.go

index 2e33ef6d20bacd7be0edd1661a6d9d1a23451de1..5d10fc1e9a184974e56fb46c2f54089b6e8ace34 100644 (file)
@@ -42,18 +42,8 @@ func ispkgin(pkgs []string) bool {
        return false
 }
 
-// TODO(rsc): Remove. Put //go:norace on forkAndExecInChild instead.
-func isforkfunc(fn *Node) bool {
-       // Special case for syscall.forkAndExecInChild.
-       // In the child, this function must not acquire any locks, because
-       // they might have been locked at the time of the fork.  This means
-       // no rescheduling, no malloc calls, and no new stack segments.
-       // Race instrumentation does all of the above.
-       return myimportpath != "" && myimportpath == "syscall" && fn.Func.Nname.Sym.Name == "forkAndExecInChild"
-}
-
 func racewalk(fn *Node) {
-       if ispkgin(omit_pkgs) || isforkfunc(fn) || fn.Func.Norace {
+       if ispkgin(omit_pkgs) || fn.Func.Norace {
                return
        }
 
index 4b5774b49207df6388e4c5cdc8d331965d05c4ba..d182896a537e789900f89acd9b33aa04e253ec2b 100644 (file)
@@ -37,6 +37,7 @@ func runtime_AfterFork()
 // For the same reason compiler does not race instrument it.
 // The calls to RawSyscall are okay because they are assembly
 // functions that do not grow the stack.
+//go:norace
 func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) {
        // Declare all variables at top in case any
        // declarations require heap allocation (e.g., err1).
index 8fe5491f9062b302898edb89bbd2a9f423e7bbd2..3e08d43bed64c1757594ea41e71f7d8b3d35da3d 100644 (file)
@@ -53,6 +53,7 @@ func runtime_AfterFork()
 // For the same reason compiler does not race instrument it.
 // The calls to RawSyscall are okay because they are assembly
 // functions that do not grow the stack.
+//go:norace
 func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) {
        // Declare all variables at top in case any
        // declarations require heap allocation (e.g., err1).
index 7a415fd31edbbd2511fd9a8019d95868aabd0f5b..490bdd71e1faa0ce0b3f47564d74a4f07c3a2b8d 100644 (file)
@@ -173,6 +173,7 @@ func init() {
 // no rescheduling, no malloc calls, and no new stack segments.
 // The calls to RawSyscall are okay because they are assembly
 // functions that do not grow the stack.
+//go:norace
 func forkAndExecInChild(argv0 *byte, argv []*byte, envv []envItem, dir *byte, attr *ProcAttr, fdsToClose []int, pipe int, rflag int) (pid int, err error) {
        // Declare all variables at top in case any
        // declarations require heap allocation (e.g., errbuf).
index 3e949f1ba1fcc758f0b06ca280e896c1ec5fa361..63fa8482da3dcc28c933e75bbe4760b0cb370459 100644 (file)
@@ -52,6 +52,7 @@ func write1(fd uintptr, buf uintptr, nbyte uintptr) (n uintptr, err Errno)
 // because we need to avoid lazy-loading the functions (might malloc,
 // split the stack, or acquire mutexes). We can't call RawSyscall
 // because it's not safe even for BSD-subsystem calls.
+//go:norace
 func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) {
        // Declare all variables at top in case any
        // declarations require heap allocation (e.g., err1).