diff options
author | Alon Zakai <azakai@google.com> | 2020-10-21 11:36:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-21 11:36:35 -0700 |
commit | 5374418d347e5adb242a2e92c3fec7aa02de8f13 (patch) | |
tree | e7632f49b90d8f8b78add95e51439863ca575ec4 /scripts/fuzz_opt.py | |
parent | ddf0b590c48448176c9821669eedac6741434bd9 (diff) | |
download | binaryen-5374418d347e5adb242a2e92c3fec7aa02de8f13.tar.gz binaryen-5374418d347e5adb242a2e92c3fec7aa02de8f13.tar.bz2 binaryen-5374418d347e5adb242a2e92c3fec7aa02de8f13.zip |
Fuzzer: Handle the case where we can't even generate the wasm file (#3270)
If we can't run the -ttf stage, there is no point in printing out the
instructions to reduce things - we can't reduce without a wasm.
Diffstat (limited to 'scripts/fuzz_opt.py')
-rwxr-xr-x | scripts/fuzz_opt.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index 1070b9868..decd01f4a 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -931,6 +931,11 @@ if __name__ == '__main__': assert os.path.getsize(raw_input_data) == input_size opts = randomize_opt_flags() print('randomized opts:', ' '.join(opts)) + # remove the generated wasm file, so that we can tell if the fuzzer + # fails to create one + if os.path.exists('a.wasm'): + os.remove('a.wasm') + # run an iteration of the fuzzer try: total_wasm_size += test_one(raw_input_data, opts, given_wasm) except KeyboardInterrupt: @@ -957,6 +962,26 @@ if __name__ == '__main__': # is likely to be called within wasm-reduce script itself, so # original.wasm and reduce.sh should not be overwritten. if not given_wasm: + # We can't do this if a.wasm doesn't exist, which can be the + # case if we failed to even generate the wasm. + if not os.path.exists('a.wasm'): + print('''\ +================================================================================ +You found a bug in the fuzzer itself! It failed to generate a valid wasm file +from the random input. Please report it with + + seed: %(seed)d + +and the exact version of Binaryen you found it on, plus the exact Python +version (hopefully deterministic random numbers will be identical). + +You can run that testcase again with "fuzz_opt.py %(seed)d" + +(We can't automatically reduce this testcase since we can only run the reducer +on valid wasm files.) +================================================================================ + ''' % {'seed': seed}) + break # show some useful info about filing a bug and reducing the # testcase (to make reduction simple, save "original.wasm" on # the side, so that we can autoreduce using the name "a.wasm" |