Skip to content

Commit 7c4a428

Browse files
authored
[Stack Switching] Trap on cont.bind of a null continuation (#8477)
Before this we asserted.
1 parent 192dcc3 commit 7c4a428

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/wasm-interpreter.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4770,9 +4770,14 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
47704770
VISIT_ARGUMENTS(flow, curr->operands, arguments)
47714771
VISIT(cont, curr->cont)
47724772

4773+
auto contValue = cont.getSingleValue();
4774+
if (contValue.isNull()) {
4775+
trap("null ref");
4776+
}
4777+
47734778
// Create a new continuation, copying the old but with the new type +
47744779
// arguments.
4775-
auto old = cont.getSingleValue().getContData();
4780+
auto old = contValue.getContData();
47764781
auto newData = *old;
47774782
newData.type = curr->type.getHeapType();
47784783
for (auto arg : arguments) {

test/lit/exec/cont_bindings.wast

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,16 @@
4343
)
4444
)
4545
)
46+
47+
;; CHECK: [fuzz-exec] calling null-binding
48+
;; CHECK-NEXT: [trap null ref]
49+
(func $null-binding (export "null-binding")
50+
(drop
51+
(cont.bind $C1 $C2
52+
(i32.const 42)
53+
(ref.null $C1)
54+
)
55+
)
56+
)
4657
)
4758

0 commit comments

Comments
 (0)