diff options
| author | Austin Clements <austin@google.com> | 2018-05-23 14:01:21 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-05-24 15:39:56 +0000 |
| commit | 29957c52df59795ba21a6832662f66e9f1f298cf (patch) | |
| tree | b683e2cf750da2578f68a0782a133748fd74f366 /src/runtime/debug_test.go | |
| parent | 65c365bf0f4add682419ba8fe68db43a0cab0e83 (diff) | |
| download | go-29957c52df59795ba21a6832662f66e9f1f298cf.tar.xz | |
runtime: fix preemption deadlocks in TestDebugCall*
TestDebugCall* uses atomic spin loops and hence can deadlock if the
garbage collector is enabled (because of #10958; ironically,
implementing debugger call injection is closely related to fixing this
exact issue, but we're not there yet).
Fix this by disabling the garbage collector during these tests.
Updates #25519 (might fix it, though I suspect not)
Change-Id: If1e454b9cdea8e4b1cd82509b762c75b6acd8476
Reviewed-on: https://go-review.googlesource.com/114086
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/debug_test.go')
| -rw-r--r-- | src/runtime/debug_test.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/runtime/debug_test.go b/src/runtime/debug_test.go index bbc86fba9e..4181d59c1f 100644 --- a/src/runtime/debug_test.go +++ b/src/runtime/debug_test.go @@ -18,14 +18,17 @@ package runtime_test import ( "fmt" "runtime" + "runtime/debug" "sync/atomic" "syscall" "testing" ) func startDebugCallWorker(t *testing.T) (g *runtime.G, after func()) { - // This can deadlock if there aren't enough threads. + // This can deadlock if there aren't enough threads or if a GC + // tries to interrupt an atomic loop (see issue #10958). ogomaxprocs := runtime.GOMAXPROCS(2) + ogcpercent := debug.SetGCPercent(-1) ready := make(chan *runtime.G) var stop uint32 @@ -39,6 +42,7 @@ func startDebugCallWorker(t *testing.T) (g *runtime.G, after func()) { t.Fatal(err) } runtime.GOMAXPROCS(ogomaxprocs) + debug.SetGCPercent(ogcpercent) } } @@ -156,8 +160,10 @@ func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *uint32) { } func TestDebugCallUnsafePoint(t *testing.T) { - // This can deadlock if there aren't enough threads. + // This can deadlock if there aren't enough threads or if a GC + // tries to interrupt an atomic loop (see issue #10958). defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2)) + defer debug.SetGCPercent(debug.SetGCPercent(-1)) // Test that the runtime refuses call injection at unsafe points. var g *runtime.G |
