mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/cgo: make compatible with race detector
Some routines run without and m or g and cannot invoke the race detector runtime. They must be opaque to the runtime. That used to be true because they were written in C. Now that they are written in Go, disable the race detector annotations for those functions explicitly. Add test. Fixes #10874. Change-Id: Ia8cc28d51e7051528f9f9594b75634e6bb66a785 Reviewed-on: https://go-review.googlesource.com/12534 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
0acecb7164
commit
75d779566b
10 changed files with 140 additions and 117 deletions
|
|
@ -42,6 +42,7 @@ 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
|
||||
|
|
@ -52,7 +53,7 @@ func isforkfunc(fn *Node) bool {
|
|||
}
|
||||
|
||||
func racewalk(fn *Node) {
|
||||
if ispkgin(omit_pkgs) || isforkfunc(fn) {
|
||||
if ispkgin(omit_pkgs) || isforkfunc(fn) || fn.Func.Norace {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue