0
1
mirror of https://github.com/golang/go synced 2025-05-29 15:20:52 +00:00

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 .

Change-Id: I4c642ebb12f737cdb0d79ccff64b6059fc3d8b34
Reviewed-on: https://go-review.googlesource.com/c/go/+/636155
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Anthony Knyszek
2024-12-13 23:18:59 +00:00
committed by Michael Knyszek
parent 18b5435fc8
commit 3bd08b9792

@ -834,7 +834,11 @@ func TestWeakToStrongMarkTermination(t *testing.T) {
done <- struct{}{}
}()
go func() {
time.Sleep(100 * time.Millisecond)
// Usleep here instead of time.Sleep. time.Sleep
// can allocate, and if we get unlucky, then it
// can end up stuck in gcMarkDone with nothing to
// wake it.
runtime.Usleep(100000) // 100ms
// Let mark termination continue.
runtime.SetSpinInGCMarkDone(false)