diff options
author | Alon Zakai <azakai@google.com> | 2024-03-05 13:41:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-05 13:41:39 -0800 |
commit | d1a7d4b8c8965a1f1c4bb22510631c28334581cb (patch) | |
tree | e31f1ef3f4559a6741e77c6eb9eaf7f443cac16f | |
parent | 6896d05ce48b63b34b6c0904eb694618ee7ac619 (diff) | |
download | binaryen-d1a7d4b8c8965a1f1c4bb22510631c28334581cb.tar.gz binaryen-d1a7d4b8c8965a1f1c4bb22510631c28334581cb.tar.bz2 binaryen-d1a7d4b8c8965a1f1c4bb22510631c28334581cb.zip |
Fuzzer: Standardize notation for exception prefixes (#6369)
We had exception: in one and exception thrown: in another. Making those
consistent allows fuzz_shell.js to print the exception after that prefix, which
makes debugging easier sometimes.
Also canonicalize tag names. Like funcref names, JS VMs print out the internal
name, which can change after opts, so canonicalize it.
-rwxr-xr-x | scripts/fuzz_opt.py | 10 | ||||
-rw-r--r-- | scripts/fuzz_shell.js | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index 4b4439e4f..0d720c8f7 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -478,6 +478,9 @@ STACK_LIMIT = '[trap stack limit]' # and also see the --dce workaround below that also links to those issues. V8_UNINITIALIZED_NONDEF_LOCAL = 'uninitialized non-defaultable local' +# JS exceptions are logged as exception thrown: REASON +EXCEPTION_PREFIX = 'exception thrown: ' + # given a call line that includes FUZZ_EXEC_CALL_PREFIX, return the export that # is called @@ -585,7 +588,7 @@ def fix_output(out): out = re.sub(r'f64\.const (-?[nanN:abcdefxIity\d+-.]+)', fix_double, out) # mark traps from wasm-opt as exceptions, even though they didn't run in a vm - out = out.replace(TRAP_PREFIX, 'exception: ' + TRAP_PREFIX) + out = out.replace(TRAP_PREFIX, EXCEPTION_PREFIX + TRAP_PREFIX) # funcref(0) has the index of the function in it, and optimizations can # change that index, so ignore it @@ -595,6 +598,9 @@ def fix_output(out): # to "N". out = re.sub(r'i31ref\((-?\d+)\)', r'\1', out) + # Tag names may change due to opts, so canonicalize them. + out = re.sub(r' tag\$\d+', ' tag', out) + lines = out.splitlines() for i in range(len(lines)): line = lines[i] @@ -604,7 +610,7 @@ def fix_output(out): # developer can see it. print(line) lines[i] = None - elif 'exception' in line: + elif EXCEPTION_PREFIX in line: # exceptions may differ when optimizing, but an exception should # occur, so ignore their types (also js engines print them out # slightly differently) diff --git a/scripts/fuzz_shell.js b/scripts/fuzz_shell.js index 6458f8126..be65ce31c 100644 --- a/scripts/fuzz_shell.js +++ b/scripts/fuzz_shell.js @@ -108,7 +108,7 @@ var instance; try { instance = new WebAssembly.Instance(module, imports); } catch (e) { - console.log('exception: failed to instantiate module'); + console.log('exception thrown: failed to instantiate module'); quit(); } @@ -143,7 +143,7 @@ for (var e in exports) { console.log('[fuzz-exec] note result: ' + e + ' => ' + printed(result)); } } catch (e) { - console.log('exception!');// + [e, e.stack]); + console.log('exception thrown: ' + e); } } |