Skip to content

Commit d8762b2

Browse files
committed
runtime: fix overflow in PingPongHog test
On 32-bit systems the result of hogCount*factor can overflow. Use division instead to do comparison. Update #52207 Change-Id: I429fb9dc009af645acb535cee5c70887527ba207 Reviewed-on: https://go-review.googlesource.com/c/go/+/407415 Reviewed-by: Michael Knyszek <[email protected]> Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent dd83fd8 commit d8762b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/runtime/proc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ func TestPingPongHog(t *testing.T) {
483483
// scheduler isn't working right, the gap should be ~1000X
484484
// (was 5, increased to 20, see issue 52207).
485485
const factor = 20
486-
if hogCount > lightCount*factor || lightCount > hogCount*factor {
486+
if hogCount/factor > lightCount || lightCount/factor > hogCount {
487487
t.Fatalf("want hogCount/lightCount in [%v, %v]; got %d/%d = %g", 1.0/factor, factor, hogCount, lightCount, float64(hogCount)/float64(lightCount))
488488
}
489489
}

0 commit comments

Comments
 (0)