Skip to content

Commit 3a38c07

Browse files
authored
[Stack Switching] Handle resuming a null (#7833)
1 parent 5602876 commit 3a38c07

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/wasm-interpreter.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4927,7 +4927,11 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
49274927
}
49284928

49294929
// Get and execute the continuation.
4930-
auto contData = flow.getSingleValue().getContData();
4930+
auto cont = flow.getSingleValue();
4931+
if (cont.isNull()) {
4932+
trap("null ref");
4933+
}
4934+
auto contData = cont.getContData();
49314935
auto func = contData->func;
49324936

49334937
// If we are resuming a nested suspend then we should just rewind the call

test/spec/cont.wast

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@
116116
(func (export "non-linear-4")
117117
(call $nl4 (cont.new $k1 (ref.func $r1)))
118118
)
119+
120+
(func (export "null")
121+
(resume $k1
122+
(ref.null $k1)
123+
)
124+
)
119125
)
120126

121127
(assert_suspension (invoke "unhandled-1") "unhandled")
@@ -132,6 +138,8 @@
132138
(assert_trap (invoke "non-linear-3") "continuation already consumed")
133139
(assert_trap (invoke "non-linear-4") "continuation already consumed")
134140

141+
(assert_trap (invoke "null") "null continuation reference")
142+
135143
(assert_invalid
136144
(module
137145
(type $ft (func))

0 commit comments

Comments
 (0)