1
0
mirror of https://github.com/golang/go synced 2024-09-25 09:20:18 -06:00
go/misc/cgo
Nikhil Benesch e496e612b7 runtime: never call into race detector with retaken P
cgocall could previously invoke the race detector on an M whose P had
been retaken. The race detector would attempt to use the P-local state
from this stale P, racing with the thread that was actually wired to
that P. The result was memory corruption of ThreadSanitizer's internal
data structures that presented as hard-to-understand assertion failures
and segfaults.

Reorder cgocall so that it always acquires a P before invoking the race
detector, and add a test that stresses the interaction between cgo and
the race detector to protect against future bugs of this kind.

Fixes #27660.

Change-Id: Ide93f96a23490314d6647547140e0a412a97f0d4
Reviewed-on: https://go-review.googlesource.com/c/148717
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2018-11-09 21:47:48 +00:00
..
errors cmd/cgo: rewrite pointer checking to use more function literals 2018-11-01 21:54:54 +00:00
fortran *.bash: always use the same string equality operator 2017-03-14 21:46:31 +00:00
gmp all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
life test: remove rundircmpout and cmpout actions 2018-05-31 17:36:45 +00:00
nocgo cmd/ld: really import runtime/cgo for external link 2014-05-20 21:36:50 -07:00
stdio test: remove rundircmpout and cmpout actions 2018-05-31 17:36:45 +00:00
test runtime: never call into race detector with retaken P 2018-11-09 21:47:48 +00:00
testasan runtime: more flexible heap memory mapping on 64-bits 2013-06-12 18:47:16 +04:00
testcarchive misc/cgo/testcarchive: make the tests work when using gccgo 2018-08-21 15:03:10 +00:00
testcshared misc/cgo/testcshared: force descriptor 30 to be closed when execing test 2018-08-01 23:10:11 +00:00
testgodefs cmd/cgo: don't resolve typedefs in -godefs mode 2018-07-27 16:46:42 +00:00
testplugin all: fix a bunch of misspellings 2018-10-06 15:40:03 +00:00
testsanitizers all: fix a bunch of misspellings 2018-10-06 15:40:03 +00:00
testshared all: fix a bunch of misspellings 2018-10-06 15:40:03 +00:00
testsigfwd misc/cgo/testsigfwd: add missing return statement 2016-08-30 21:44:14 +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