Skip to content

Commit 3d7c4cf

Browse files
authored
Avoid fuzzing with multiple --flatten operations, which causes exponential overhead (#2345)
1 parent 159e9a4 commit 3d7c4cf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

scripts/fuzz_opt.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,11 @@ def get_multiple_opt_choices():
511511
ret = []
512512
# core opts
513513
while 1:
514-
ret += random.choice(opt_choices)
514+
choice = random.choice(opt_choices)
515+
if '--flatten' in ret and '--flatten' in choice:
516+
print('avoiding multiple --flatten in a single command, due to exponential overhead')
517+
else:
518+
ret += choice
515519
if len(ret) > 20 or random.random() < 0.3:
516520
break
517521
# modifiers (if not already implied by a -O? option)
@@ -520,6 +524,7 @@ def get_multiple_opt_choices():
520524
ret += ['--optimize-level=' + str(random.randint(0, 3))]
521525
if random.random() < 0.5:
522526
ret += ['--shrink-level=' + str(random.randint(0, 3))]
527+
assert ret.count('--flatten') <= 1
523528
return ret
524529

525530

0 commit comments

Comments
 (0)