From 066620f0d8597116a62d9423669ca569646de5ff Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 23 Nov 2021 14:30:56 +0000 Subject: [PATCH] runtime: ensure no GC is running in TestParallelRWMutexReaders Currently this test makes it clear that it's unsafe for a GC to run, otherwise a deadlock could occur, so it calls SetGCPercent(-1). However, a GC may be actively in progress, and SetGCPercent is not going to end any in-progress GC. Call runtime.GC to block until at least the current GC is over. Updates #49680. Change-Id: Ibdc7d378e8cf7e05270910e92effcad8c6874e59 Reviewed-on: https://go-review.googlesource.com/c/go/+/366534 Trust: Michael Knyszek Run-TryBot: Michael Knyszek Reviewed-by: Than McIntosh Reviewed-by: Cherry Mui --- src/runtime/rwmutex_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/rwmutex_test.go b/src/runtime/rwmutex_test.go index 291a32ea5e..33ddd7d1d5 100644 --- a/src/runtime/rwmutex_test.go +++ b/src/runtime/rwmutex_test.go @@ -55,6 +55,9 @@ func TestParallelRWMutexReaders(t *testing.T) { // since the goroutines can't be stopped/preempted. // Disable GC for this test (see issue #10958). defer debug.SetGCPercent(debug.SetGCPercent(-1)) + // Finish any in-progress GCs and get ourselves to a clean slate. + GC() + doTestParallelReaders(1) doTestParallelReaders(3) doTestParallelReaders(4) -- 2.48.1