summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/update_lit_checks.py6
-rw-r--r--src/tools/execution-results.h14
-rw-r--r--test/lit/exec/host-limit.wast27
3 files changed, 43 insertions, 4 deletions
diff --git a/scripts/update_lit_checks.py b/scripts/update_lit_checks.py
index b93059427..1e7274c51 100755
--- a/scripts/update_lit_checks.py
+++ b/scripts/update_lit_checks.py
@@ -155,6 +155,12 @@ def parse_output_fuzz_exec(text):
# in the input.
name = f'"{func.group("name")}"'
items.append((('func', name), [line]))
+ elif line.startswith('[host limit'):
+ # Skip mentions of host limits that we hit. This can happen even
+ # before we reach the execution of a function (if it happens during
+ # instantiation of the module), in which case |items| may be empty,
+ # and we'd error on the code below.
+ pass
elif line:
assert items, 'unexpected non-invocation line'
items[-1][1].append(line)
diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h
index 17101e0ab..4ef087cec 100644
--- a/src/tools/execution-results.h
+++ b/src/tools/execution-results.h
@@ -131,9 +131,12 @@ struct ExecutionResults {
}
}
} catch (const TrapException&) {
- // may throw in instance creation (init of offsets)
+ // May throw in instance creation (init of offsets).
} catch (const HostLimitException&) {
- // may throw in instance creation (e.g. array.new of huge size)
+ // May throw in instance creation (e.g. array.new of huge size).
+ // This should be ignored and not compared with, as optimizations can
+ // change whether a host limit is reached.
+ ignore = true;
}
}
@@ -221,10 +224,13 @@ struct ExecutionResults {
ModuleRunner instance(wasm, &interface);
return run(func, wasm, instance);
} catch (const TrapException&) {
- // may throw in instance creation (init of offsets)
+ // May throw in instance creation (init of offsets).
return {};
} catch (const HostLimitException&) {
- // may throw in instance creation (e.g. array.new of huge size)
+ // May throw in instance creation (e.g. array.new of huge size).
+ // This should be ignored and not compared with, as optimizations can
+ // change whether a host limit is reached.
+ ignore = true;
return {};
}
}
diff --git a/test/lit/exec/host-limit.wast b/test/lit/exec/host-limit.wast
new file mode 100644
index 000000000..ee59d655b
--- /dev/null
+++ b/test/lit/exec/host-limit.wast
@@ -0,0 +1,27 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited.
+
+;; RUN: wasm-opt %s -all --remove-unused-module-elements --fuzz-exec -o /dev/null 2>&1 | filecheck %s
+
+;; The global here can be optimized out as it has no uses. That has a noticeable
+;; effect, however, of avoiding a host limit exception. We should ignore that in
+;; fuzz exec and not error.
+
+(module
+ (type $type$0 (array i8))
+
+ (import "fuzzing-support" "log" (func $log (param i32)))
+
+ (global $global (mut (ref $type$0)) (array.new_default $type$0
+ (i32.const -1)
+ ))
+
+ ;; CHECK: [fuzz-exec] calling export
+ ;; CHECK-NEXT: [LoggingExternalInterface logging 42]
+ ;; CHECK-NEXT: ignoring comparison of ExecutionResults!
+ (func "export"
+ (call $log
+ (i32.const 42)
+ )
+ )
+)
+