From 0974a138279537d4ac20ca00df67a116955b18c0 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 12 Dec 2024 09:36:22 -0800 Subject: [PATCH] fix --- src/tools/execution-results.h | 10 +++++----- test/lit/exec/fuzzing-api.wast | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index bffc4e8f2b2..b8823c3f0a5 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -187,8 +187,8 @@ struct LoggingExternalInterface : public ShellExternalInterface { Literals arguments; for (const auto& param : func->getParams()) { // An i64 param can work from JS, but fuzz_shell provides 0, which errors - // on attempts to convert it to BigInt. v128 cannot work at all. - if (param == Type::i64 || param == Type::v128) { + // on attempts to convert it to BigInt. v128 and exnref are disalloewd. + if (param == Type::i64 || param == Type::v128 || param.isExn()) { throwEmptyException(); } if (!param.isDefaultable()) { @@ -200,9 +200,9 @@ struct LoggingExternalInterface : public ShellExternalInterface { // Error on illegal results. Note that this happens, as per JS semantics, // *before* the call. for (const auto& result : func->getResults()) { - // An i64 result is fine: a BigInt will be provided. But v128 still - // errors. - if (result == Type::v128) { + // An i64 result is fine: a BigInt will be provided. But v128 and exnref + // still error. + if (result == Type::v128 || result.isExn()) { throwEmptyException(); } } diff --git a/test/lit/exec/fuzzing-api.wast b/test/lit/exec/fuzzing-api.wast index eae95fc0a87..7c975cb7536 100644 --- a/test/lit/exec/fuzzing-api.wast +++ b/test/lit/exec/fuzzing-api.wast @@ -218,6 +218,24 @@ ) ) + (func $illegal-exnref (param $x exnref) + ;; Helper for the function below. + (call $log-i32 + (i32.const 57) + ) + ) + + ;; CHECK: [fuzz-exec] calling ref.calling.illegal-exnref + ;; CHECK-NEXT: [LoggingExternalInterface logging 1] + (func $ref.calling.illegal-exnref (export "ref.calling.illegal-exnref") + ;; As above, we throw on the exnref param, and log 1. + (call $log-i32 + (call $call.ref.catch + (ref.func $illegal-exnref) + ) + ) + ) + (func $illegal-result (result v128) ;; Helper for the function below. The result is illegal for JS. (call $log-i32 @@ -324,6 +342,9 @@ ;; CHECK: [fuzz-exec] calling ref.calling.illegal-v128 ;; CHECK-NEXT: [LoggingExternalInterface logging 1] +;; CHECK: [fuzz-exec] calling ref.calling.illegal-exnref +;; CHECK-NEXT: [LoggingExternalInterface logging 1] + ;; CHECK: [fuzz-exec] calling ref.calling.illegal-result ;; CHECK-NEXT: [LoggingExternalInterface logging 1] @@ -339,6 +360,7 @@ ;; CHECK-NEXT: [fuzz-exec] comparing ref.calling ;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.catching ;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal +;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal-exnref ;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal-result ;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.illegal-v128 ;; CHECK-NEXT: [fuzz-exec] comparing ref.calling.legal