1
0
mirror of https://github.com/golang/go synced 2024-10-03 22:31:21 -06:00
go/misc/cgo
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
..
errors cmd/cgo: remove -O options when generating compiler errors 2016-05-27 01:40:30 +00:00
fortran misc/cgo/fortran: fix gfortran compile test 2016-05-04 15:08:16 +00:00
gmp all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
life all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
nocgo cmd/ld: really import runtime/cgo for external link 2014-05-20 21:36:50 -07:00
stdio all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
test misc/cgo/test: add mips64x test case for issue9400 2016-05-04 16:41:36 +00:00
testasan runtime: more flexible heap memory mapping on 64-bits 2013-06-12 18:47:16 +04:00
testcarchive cmd/go: add -shared to darwin/arm{,64} default build mode 2016-05-07 18:58:39 +00:00
testcshared all: fix spelling mistakes 2016-04-03 17:03:15 +00:00
testgodefs all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
testsanitizers runtime/cgo: add TSAN acquire/release calls 2016-05-31 20:53:16 +00:00
testshared cmd/link: always read type data for dynimport symbols 2016-05-04 07:13:01 +00:00
testsigfwd runtime: for c-archive/c-shared, don't install unnecessary signal handlers 2015-12-18 22:27:38 +00:00
testso cmd/dist: convert testso test into Go 2015-06-12 04:33:50 +00:00
testsovar misc/cgo/testsovar: needs the extern keyword to export variables on non-windows platforms 2015-07-21 18:10:57 +00:00
testtls all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00