]> Cypherpunks repositories - gostls13.git/commit
runtime/cgo: add TSAN acquire/release calls
authorIan Lance Taylor <iant@golang.org>
Fri, 27 May 2016 00:47:03 +0000 (17:47 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 31 May 2016 20:53:16 +0000 (20:53 +0000)
commit66736880ca2e50fc7c5428a171fbbe6d344a853b
tree419a3c55e891e5e0a9bee219be22dcc444857944
parent0e13dbc1a91cbe00e3c83a55f56db69380fe8f68
runtime/cgo: add TSAN acquire/release calls

Add TSAN acquire/release calls to runtime/cgo to match the ones
generated by cgo.  This avoids a false positive race around the malloc
memory used in runtime/cgo when other goroutines are simultaneously
calling malloc and free from cgo.

These new calls will only be used when building with CGO_CFLAGS and
CGO_LDFLAGS set to -fsanitize=thread, which becomes a requirement to
avoid all false positives when using TSAN.  These are needed not just
for runtime/cgo, but also for any runtime package that uses cgo (such as
net and os/user).

Add an unused attribute to the _cgo_tsan_acquire and _cgo_tsan_release
functions, in case there are no actual cgo function calls.

Add a test that checks that setting CGO_CFLAGS/CGO_LDFLAGS avoids a
false positive report when using os/user.

Change-Id: I0905c644ff7f003b6718aac782393fa219514c48
Reviewed-on: https://go-review.googlesource.com/23492
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
misc/cgo/testsanitizers/test.bash
misc/cgo/testsanitizers/tsan5.go [new file with mode: 0644]
src/cmd/cgo/out.go
src/runtime/cgo/gcc_linux_amd64.c
src/runtime/cgo/gcc_util.c
src/runtime/cgo/libcgo.h