aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/lock_futex.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2017-01-19 16:09:10 -0500
committerBryan Mills <bcmills@google.com>2017-03-08 18:58:30 +0000
commit29edf0f9feb0e7412788a20e7d8d473270cb9342 (patch)
tree79729212f998917d70ded0c35199096d3e6dd062 /src/runtime/lock_futex.go
parentd71f36b5aa1eadc6cd86ada2c0d5dd621bd9fd82 (diff)
downloadgo-29edf0f9feb0e7412788a20e7d8d473270cb9342.tar.gz
go-29edf0f9feb0e7412788a20e7d8d473270cb9342.zip
runtime: poll libc to deliver signals under TSAN
fixes #18717 Change-Id: I7244463d2e7489e0b0fe3b74c4b782e71210beb2 Reviewed-on: https://go-review.googlesource.com/35494 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/lock_futex.go')
-rw-r--r--src/runtime/lock_futex.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/runtime/lock_futex.go b/src/runtime/lock_futex.go
index 073136abd0..341c74ff39 100644
--- a/src/runtime/lock_futex.go
+++ b/src/runtime/lock_futex.go
@@ -140,9 +140,17 @@ func notesleep(n *note) {
if gp != gp.m.g0 {
throw("notesleep not on g0")
}
+ ns := int64(-1)
+ if _cgo_yield != nil {
+ // Sleep for an arbitrary-but-moderate interval to poll libc interceptors.
+ ns = 10e6
+ }
for atomic.Load(key32(&n.key)) == 0 {
gp.m.blocked = true
- futexsleep(key32(&n.key), 0, -1)
+ futexsleep(key32(&n.key), 0, ns)
+ if _cgo_yield != nil {
+ asmcgocall(_cgo_yield, nil)
+ }
gp.m.blocked = false
}
}
@@ -156,9 +164,16 @@ func notetsleep_internal(n *note, ns int64) bool {
gp := getg()
if ns < 0 {
+ if _cgo_yield != nil {
+ // Sleep for an arbitrary-but-moderate interval to poll libc interceptors.
+ ns = 10e6
+ }
for atomic.Load(key32(&n.key)) == 0 {
gp.m.blocked = true
- futexsleep(key32(&n.key), 0, -1)
+ futexsleep(key32(&n.key), 0, ns)
+ if _cgo_yield != nil {
+ asmcgocall(_cgo_yield, nil)
+ }
gp.m.blocked = false
}
return true