aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prog/rand.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/prog/rand.go b/prog/rand.go
index cfe20fb0b..a115b22ec 100644
--- a/prog/rand.go
+++ b/prog/rand.go
@@ -231,7 +231,9 @@ func (r *randGen) flags(vv []uint64, bitmask bool, oldVal uint64) uint64 {
}
// We don't want to return 0 here, because we already given 0
// fixed probability above (otherwise we get 0 too frequently).
- for v == 0 || r.nOutOf(2, 3) {
+ // Note: this loop can hang if all values are equal to 0. We don't generate such flags in the compiler now,
+ // but it used to hang occasionally, so we keep the try < 10 logic b/c we don't have a local check for values.
+ for try := 0; try < 10 && (v == 0 || r.nOutOf(2, 3)); try++ {
flag := vv[r.rand(len(vv))]
if r.oneOf(20) {
// Try choosing adjacent bit values in case we forgot