]> Cypherpunks repositories - gostls13.git/commit
runtime: fix _cgo_yield usage with sysmon and on BSD
authorBryan C. Mills <bcmills@google.com>
Wed, 8 Mar 2017 20:40:28 +0000 (15:40 -0500)
committerBryan Mills <bcmills@google.com>
Thu, 9 Mar 2017 18:36:49 +0000 (18:36 +0000)
commite57350f4c091c80333d37b2ba5af50de193147fa
tree098600707caa738dbdfb46d5adb5f180a443e12c
parent91563ced5897faf729a34be7081568efcfedda31
runtime: fix _cgo_yield usage with sysmon and on BSD

There are a few problems from change 35494, discovered during testing
of change 37852.

1. I was confused about the usage of n.key in the sema variant, so we
   were looping on the wrong condition. The error was not caught by
   the TryBots (presumably due to missing TSAN coverage in the BSD and
   darwin builders?).

2. The sysmon goroutine sometimes skips notetsleep entirely, using
   direct usleep syscalls instead. In that case, we were not calling
   _cgo_yield, leading to missed signals under TSAN.

3. Some notetsleep calls have long finite timeouts. They should be
   broken up into smaller chunks with a yield at the end of each
   chunk.

updates #18717

Change-Id: I91175af5dea3857deebc686f51a8a40f9d690bcc
Reviewed-on: https://go-review.googlesource.com/37867
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/testsanitizers/test.bash
misc/cgo/testsanitizers/tsan11.go [new file with mode: 0644]
src/runtime/lock_futex.go
src/runtime/lock_sema.go
src/runtime/proc.go