From bcc4422ee1bdb8051a6c870cf00e837814614a0f Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 6 Apr 2021 14:55:46 -0400 Subject: [PATCH] runtime: deflake TestGCTestIsReachable This is a simple workaround for a bug where runtime.GC() can return before finishing a full sweep, causing gcTestIsReachable to throw. The right thing is to fix runtime.GC(), but this should get this test passing reliably in the meantime. Updates #45315. Change-Id: Iae141e6dbb26a9c2649497c1feedd4aaeaf540c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/307809 Trust: Austin Clements Run-TryBot: Austin Clements Reviewed-by: Michael Knyszek TryBot-Result: Go Bot --- src/runtime/mgc.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 4c165ddcdb..ef3436d1f4 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -2391,6 +2391,11 @@ func gcTestIsReachable(ptrs ...unsafe.Pointer) (mask uint64) { // Force a full GC and sweep. GC() + // TODO(austin): Work around issue #45315. One GC() can return + // without finishing the sweep. Do a second to force the sweep + // through. + GC() + // Process specials. for i, s := range specials { if !s.done { -- 2.48.1