summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-10-23 10:17:13 -0700
committerGitHub <noreply@github.com>2024-10-23 10:17:13 -0700
commitdcc70bbfb16c2f8fce29dad94d80d1b78123655f (patch)
tree05db3b38ea848cef1010eac458549f012342b2fa /scripts
parent0d9b7508e5de1ca7befef493ed3e357b8a5613a1 (diff)
downloadbinaryen-dcc70bbfb16c2f8fce29dad94d80d1b78123655f.tar.gz
binaryen-dcc70bbfb16c2f8fce29dad94d80d1b78123655f.tar.bz2
binaryen-dcc70bbfb16c2f8fce29dad94d80d1b78123655f.zip
[EH] Fuzz throws from JS (#7027)
We already generated (throw ..) instructions in wasm, but it makes sense to model throws from outside as well, as they cross the module boundary. This adds a new fuzzer import to the generated modules, "throw", that just does a throw from JS etc. Also be more precise about handling fuzzing-support imports in fuzz-exec: we now check that logging functions start with "log*" and error otherwise (this check is now needed given we have "throw", which is not logging). Also fix a minor issue with name conflicts for logging functions by using getValidFunctionName for them, both for logging and for throw.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fuzz_shell.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/fuzz_shell.js b/scripts/fuzz_shell.js
index 3d29b197c..4cf3ba358 100644
--- a/scripts/fuzz_shell.js
+++ b/scripts/fuzz_shell.js
@@ -138,6 +138,7 @@ function logValue(x, y) {
var tempRet0;
var imports = {
'fuzzing-support': {
+ // Logging.
'log-i32': logValue,
'log-i64': logValue,
'log-f32': logValue,
@@ -147,7 +148,13 @@ var imports = {
// we could avoid running JS on code with SIMD in it, but it is useful to
// fuzz such code as much as we can.)
'log-v128': logValue,
+
+ // Throw an exception from JS.
+ 'throw': () => {
+ throw 'some JS error';
+ }
},
+ // Emscripten support.
'env': {
'setTempRet0': function(x) { tempRet0 = x },
'getTempRet0': function() { return tempRet0 },