1
0
mirror of https://github.com/golang/go synced 2024-09-29 16:34:31 -06:00
go/misc/cgo/testsanitizers
Ian Lance Taylor 66736880ca 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>
2016-05-31 20:53:16 +00:00
..
msan2.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
msan3.go cmd/cgo, runtime: exported Go functions can't return a Go pointer 2015-11-19 18:28:39 +00:00
msan4.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
msan_fail.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
msan.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
test.bash runtime/cgo: add TSAN acquire/release calls 2016-05-31 20:53:16 +00:00
tsan2.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
tsan3.go cmd/cgo: mark stub functions as no_sanitize_thread 2016-05-19 17:29:13 +00:00
tsan4.go cmd/cgo, runtime, runtime/cgo: TSAN support for malloc 2016-05-25 23:22:24 +00:00
tsan5.go runtime/cgo: add TSAN acquire/release calls 2016-05-31 20:53:16 +00:00
tsan.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00