Commit c7dc5e92 authored by Than McIntosh's avatar Than McIntosh

test: tweak test to avoid unpreemptible loop with gccgo

This test contains a very tight loop with locking/unlocking that can
wind up as an unpreemptible when compiled with gccgo, depending on
inlining. Tweak the test slightly to avoid this problem.

Change-Id: I155fd2b4bfea961244eb6c6594c24ab03d32d41c
Reviewed-on: https://go-review.googlesource.com/c/go/+/193619
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent d4a6a266
...@@ -1950,11 +1950,20 @@ func test27660(t *testing.T) { ...@@ -1950,11 +1950,20 @@ func test27660(t *testing.T) {
// increase the likelihood that the race described in #27660 // increase the likelihood that the race described in #27660
// results in corruption of ThreadSanitizer's internal state // results in corruption of ThreadSanitizer's internal state
// and thus an assertion failure or segfault. // and thus an assertion failure or segfault.
i := 0
for ctx.Err() == nil { for ctx.Err() == nil {
j := rand.Intn(100) j := rand.Intn(100)
locks[j].Lock() locks[j].Lock()
ints[j]++ ints[j]++
locks[j].Unlock() locks[j].Unlock()
// needed for gccgo, to avoid creation of an
// unpreemptible "fast path" in this loop. Choice
// of (1<<24) is somewhat arbitrary.
if i%(1<<24) == 0 {
runtime.Gosched()
}
i++
} }
}() }()
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment