summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2022-08-04 12:10:01 -0700
committerGitHub <noreply@github.com>2022-08-04 19:10:01 +0000
commit9c6849b6c53c216ba8656d68fd0fd99dca5e462c (patch)
tree3d08a6ade4714b9ce7407f657676c40fe1fd0955
parent80a3c70813966f62dfe8157b983d598b5e4520ff (diff)
downloadbinaryen-9c6849b6c53c216ba8656d68fd0fd99dca5e462c.tar.gz
binaryen-9c6849b6c53c216ba8656d68fd0fd99dca5e462c.tar.bz2
binaryen-9c6849b6c53c216ba8656d68fd0fd99dca5e462c.zip
Bail out of fuzz_shell.js if instantiation fails (#4873)
Sometimes the fuzzer produces valid modules that trap during instantiation. When that happens, the JS harness used to run the fuzzer output in d8 would previously throw an error, creating spurious fuzzer failures on valid modules. Update fuzz_shell.js to catch and supress errors during instantiation (but not validation) to avoid these spurious failures. Fixes #4865.
-rw-r--r--scripts/fuzz_shell.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/fuzz_shell.js b/scripts/fuzz_shell.js
index d55007b18..0f413c2e6 100644
--- a/scripts/fuzz_shell.js
+++ b/scripts/fuzz_shell.js
@@ -175,7 +175,15 @@ var imports = {
imports = Asyncify.instrumentImports(imports);
// Create the wasm.
-var instance = new WebAssembly.Instance(new WebAssembly.Module(binary), imports);
+var module = new WebAssembly.Module(binary);
+
+var instance;
+try {
+ instance = new WebAssembly.Instance(module, imports);
+} catch (e) {
+ console.log('exception: failed to instantiate module');
+ quit();
+}
// Handle the exports.
var exports = instance.exports;
@@ -216,4 +224,3 @@ sortedExports.forEach(function(e) {
// Finish up
Asyncify.finish();
-