]> Cypherpunks repositories - gostls13.git/commit
runtime/cgo: defeat inlining in x_cgo_yield
authorBryan C. Mills <bcmills@google.com>
Mon, 7 Aug 2017 23:30:03 +0000 (19:30 -0400)
committerBryan Mills <bcmills@google.com>
Wed, 16 Aug 2017 18:49:38 +0000 (18:49 +0000)
commite0545faf270fdbc0b3864db62f528eb36da3c63f
tree1214c23536e085230a0e52238f832b843e128d97
parent58f84fdf29ca2f014a813991cf35e52de91a43cb
runtime/cgo: defeat inlining in x_cgo_yield

We use a call to strncpy to work around a TSAN bug (wherein TSAN only
delivers asynchronous signals when the thread receiving the signal
calls a libc function). Unfortunately, GCC 7 inlines the call,
avoiding the TSAN libc trap entirely.

Per Ian's suggestion, use global variables as strncpy arguments: that
way, the compiler can't make any assumptions about the concrete values
and can't inline the call away.

fixes #21196

Change-Id: Ie95f1feaf9af1a8056f924f49c29cfc8515385d7
Reviewed-on: https://go-review.googlesource.com/55872
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/cgo/gcc_util.c