aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2021-11-23 14:30:56 +0000
committerMichael Knyszek <mknyszek@google.com>2021-11-23 16:00:03 +0000
commit066620f0d8597116a62d9423669ca569646de5ff (patch)
treec11260074139f826b422ed360f6162a2d5fa8db4 /src/runtime
parent83bfed916b97d51646b4bdc95e0e0fd7798b754f (diff)
downloadgo-066620f0d8597116a62d9423669ca569646de5ff.tar.gz
go-066620f0d8597116a62d9423669ca569646de5ff.zip
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 <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/rwmutex_test.go3
1 files changed, 3 insertions, 0 deletions
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)