]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo: mark stub functions as no_sanitize_thread
authorIan Lance Taylor <iant@golang.org>
Thu, 19 May 2016 17:07:41 +0000 (10:07 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 19 May 2016 17:29:13 +0000 (17:29 +0000)
commit79ba1e44c7c2d7ff186f9ac142a85869f352f0f6
tree164224741551095e0435be1b155a097b3c39fc2e
parent0dcd330bc8ab19db15b4517b80e940cf154071bc
cmd/cgo: mark stub functions as no_sanitize_thread

When the generated stub functions write back the results to the stack,
they can in some cases be writing to the same memory on the g0 stack.
There is no race here (assuming there is no race in the Go code), but
the thread sanitizer does not know that.  Turn off the thread sanitizer
for the stub functions to prevent false positive warnings.

Current clang suggests the no_sanitize("thread") attribute, but that
does not work with clang 3.6 or GCC.  clang 3.6, GCC, and current clang
all support the no_sanitize_thread attribute, so use that
unconditionally.

The test case and first version of the patch are from Dmitriy Vyukov.

Change-Id: I80ce92824c6c8cf88ea0fe44f21cf50cf62474c9
Reviewed-on: https://go-review.googlesource.com/23252
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
misc/cgo/testsanitizers/test.bash
misc/cgo/testsanitizers/tsan3.go [new file with mode: 0644]
src/cmd/cgo/out.go