Skip to content

Commit 0481320

Browse files
authored
Fuzzer: Do not run other VMs if the Binaryen interpreter hits a VM limitation (#6483)
The VM limitation might be an OOM (which can change due to opts) or an atomic wait (which can hang on proper VMs with support). We already avoided running VMs on the optimized wasm in this case, but we still ran them on the original wasm, which this changes, mainly to avoid that atomic wait situation.
1 parent 6236dc3 commit 0481320

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

scripts/fuzz_opt.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -947,30 +947,39 @@ def can_compare_to_others(self):
947947

948948
def handle_pair(self, input, before_wasm, after_wasm, opts):
949949
global ignored_vm_runs
950-
ignored_before = ignored_vm_runs
951950

952951
before = self.run_vms(before_wasm)
953952

954-
# if the binaryen interpreter hit a host limitation on the original
955-
# testcase, or for some other reason we need to ignore this, then stop
956-
# (otherwise, a host limitation on say allocations may be hit in the
957-
# 'before' but not in the 'after' as optimizations may remove it).
958-
if before[self.bynterpreter] == IGNORE:
959-
# the ignoring should have been noted during run_vms()
960-
assert(ignored_vm_runs > ignored_before)
961-
return
962-
963953
after = self.run_vms(after_wasm)
964954
self.compare_before_and_after(before, after)
965955

966956
def run_vms(self, wasm):
957+
ignored_before = ignored_vm_runs
958+
967959
# vm_results will map vms to their results
968960
vm_results = {}
969961
for vm in self.vms:
970962
if vm.can_run(wasm):
971963
print(f'[CompareVMs] running {vm.name}')
972964
vm_results[vm] = fix_output(vm.run(wasm))
973965

966+
# If the binaryen interpreter hit a host limitation then do not
967+
# run other VMs, as that is risky: the host limitation may be an
968+
# an OOM which could be very costly (lots of swapping, and the
969+
# OOM may change after opts that remove allocations etc.), or it
970+
# might be an atomic wait which other VMs implement fully (and
971+
# the wait might be very long). In general host limitations
972+
# should be rare (which can be verified by looking at the
973+
# details of how many things we ended up ignoring), and when we
974+
# see one we are in a situation that we can't fuzz properly.
975+
if vm == self.bynterpreter and vm_results[vm] == IGNORE:
976+
print('(ignored, so not running other VMs)')
977+
978+
# the ignoring should have been noted during run_vms()
979+
assert(ignored_vm_runs > ignored_before)
980+
981+
return vm_results
982+
974983
# compare between the vms on this specific input
975984
first_vm = None
976985
for vm in vm_results.keys():

0 commit comments

Comments
 (0)