Skip to content

Commit 3bd08b9

Browse files
committed
runtime: usleep in TestWeakToStrongMarkTermination
There's a subtle bug in this test (big surprise): time.Sleep allocates, so the time.Sleep(100*time.Millisecond) before unblocking gcMarkDone might itself end up in gcMarkDone. Work around this by using usleep here instead. Fixes #70532. Change-Id: I4c642ebb12f737cdb0d79ccff64b6059fc3d8b34 Reviewed-on: https://go-review.googlesource.com/c/go/+/636155 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 18b5435 commit 3bd08b9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/runtime/gc_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,11 @@ func TestWeakToStrongMarkTermination(t *testing.T) {
834834
done <- struct{}{}
835835
}()
836836
go func() {
837-
time.Sleep(100 * time.Millisecond)
837+
// Usleep here instead of time.Sleep. time.Sleep
838+
// can allocate, and if we get unlucky, then it
839+
// can end up stuck in gcMarkDone with nothing to
840+
// wake it.
841+
runtime.Usleep(100000) // 100ms
838842

839843
// Let mark termination continue.
840844
runtime.SetSpinInGCMarkDone(false)

0 commit comments

Comments
 (0)