Skip to content

Commit 52bc45f

Browse files
authored
Execution results: JS traps on exnref on the boundary (WebAssembly#7147)
Fixes WebAssembly#7145
1 parent 0b54d74 commit 52bc45f

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/tools/execution-results.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ struct LoggingExternalInterface : public ShellExternalInterface {
187187
Literals arguments;
188188
for (const auto& param : func->getParams()) {
189189
// An i64 param can work from JS, but fuzz_shell provides 0, which errors
190-
// on attempts to convert it to BigInt. v128 cannot work at all.
191-
if (param == Type::i64 || param == Type::v128) {
190+
// on attempts to convert it to BigInt. v128 and exnref are disalloewd.
191+
if (param == Type::i64 || param == Type::v128 || param.isExn()) {
192192
throwEmptyException();
193193
}
194194
if (!param.isDefaultable()) {
@@ -200,9 +200,9 @@ struct LoggingExternalInterface : public ShellExternalInterface {
200200
// Error on illegal results. Note that this happens, as per JS semantics,
201201
// *before* the call.
202202
for (const auto& result : func->getResults()) {
203-
// An i64 result is fine: a BigInt will be provided. But v128 still
204-
// errors.
205-
if (result == Type::v128) {
203+
// An i64 result is fine: a BigInt will be provided. But v128 and exnref
204+
// still error.
205+
if (result == Type::v128 || result.isExn()) {
206206
throwEmptyException();
207207
}
208208
}

test/lit/exec/fuzzing-api.wast

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,24 @@
218218
)
219219
)
220220

221+
(func $illegal-exnref (param $x exnref)
222+
;; Helper for the function below.
223+
(call $log-i32
224+
(i32.const 57)
225+
)
226+
)
227+
228+
;; CHECK: [fuzz-exec] calling ref.calling.illegal-exnref
229+
;; CHECK-NEXT: [LoggingExternalInterface logging 1]
230+
(func $ref.calling.illegal-exnref (export "ref.calling.illegal-exnref")
231+
;; As above, we throw on the exnref param, and log 1.
232+
(call $log-i32
233+
(call $call.ref.catch
234+
(ref.func $illegal-exnref)
235+
)
236+
)
237+
)
238+
221239
(func $illegal-result (result v128)
222240
;; Helper for the function below. The result is illegal for JS.
223241
(call $log-i32
@@ -324,6 +342,9 @@
324342
;; CHECK: [fuzz-exec] calling ref.calling.illegal-v128
325343
;; CHECK-NEXT: [LoggingExternalInterface logging 1]
326344

345+
;; CHECK: [fuzz-exec] calling ref.calling.illegal-exnref
346+
;; CHECK-NEXT: [LoggingExternalInterface logging 1]
347+
327348
;; CHECK: [fuzz-exec] calling ref.calling.illegal-result
328349
;; CHECK-NEXT: [LoggingExternalInterface logging 1]
329350

@@ -339,6 +360,7 @@
339360
;; CHECK-NEXT: [fuzz-exec] comparing ref.calling
340361
;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.catching
341362
;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal
363+
;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal-exnref
342364
;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal-result
343365
;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal-v128
344366
;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.legal

0 commit comments

Comments
 (0)