mirror of
https://github.com/golang/go
synced 2024-11-23 23:30:10 -07:00
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>
This commit is contained in:
parent
83bfed916b
commit
066620f0d8
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user