diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 56fccaebebe..6b4333746ed 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -5156,6 +5156,9 @@ class ModuleRunnerBase : public ExpressionRunner { } else { // resume_throw_ref contData->exception = arguments[0]; + if (contData->exception.isNull()) { + trap("null ref"); + } } } diff --git a/test/lit/exec/resume_throw_ref.wast b/test/lit/exec/resume_throw_ref.wast new file mode 100644 index 00000000000..43518f3b2e3 --- /dev/null +++ b/test/lit/exec/resume_throw_ref.wast @@ -0,0 +1,24 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items --output=fuzz-exec and should not be edited. + +;; RUN: wasm-opt %s -all --fuzz-exec-before -q -o /dev/null 2>&1 | filecheck %s + +(module + (type $empty (func)) + (type $cont (cont $empty)) + + (func $empty + ) + + ;; CHECK: [fuzz-exec] export test + ;; CHECK-NEXT: [trap null ref] + (func $test (export "test") + ;; The exnref here is null, which we trap on. + (resume_throw_ref $cont + (ref.null noexn) + (cont.new $cont + (ref.func $empty) + ) + ) + ) +) +