Skip to content

Commit 3133a28

Browse files
authored
[Stack Switching] Reset the continuation state in --fuzz-exec on unhandled suspends (#7823)
Like wasm-shell, we must reset the global state in such a case.
1 parent 0f58d24 commit 3133a28

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

scripts/test/fuzzing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
'vacuum-stack-switching.wast',
115115
'cont.wast',
116116
'cont_simple.wast',
117+
'cont_many_unhandled.wast',
117118
# TODO: fix split_wast() on tricky escaping situations like a string ending
118119
# in \\" (the " is not escaped - there is an escaped \ before it)
119120
'string-lifting-section.wast',

src/tools/execution-results.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ struct ExecutionResults {
476476
auto flow = instance.callFunction(func->name, arguments);
477477
if (flow.suspendTag) { // TODO: support stack switching here
478478
std::cout << "[exception thrown: unhandled suspend]" << std::endl;
479+
instance.clearContinuationStore();
479480
return Exception{};
480481
}
481482
return flow.values;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited.
2+
3+
;; RUN: foreach %s %t wasm-opt -all --fuzz-exec-before -q -o /dev/null 2>&1 | filecheck %s
4+
5+
;; Three exports, one which throws from a resume, and two that do unhandled
6+
;; suspends. This is a regression test for a bug where the global state of
7+
;; continuations got into a confused state at the last export, and asserted.
8+
9+
(module
10+
(type $none (func))
11+
(type $cont (cont $none))
12+
13+
(tag $tag (type $none))
14+
15+
(func $empty
16+
)
17+
18+
;; CHECK: [fuzz-exec] calling a
19+
;; CHECK-NEXT: [exception thrown: tag ()]
20+
(func $a (export "a")
21+
(resume_throw $cont $tag
22+
(cont.new $cont
23+
(ref.func $empty)
24+
)
25+
)
26+
)
27+
28+
;; CHECK: [fuzz-exec] calling b
29+
;; CHECK-NEXT: [exception thrown: unhandled suspend]
30+
(func $b (export "b")
31+
(suspend $tag)
32+
)
33+
34+
;; CHECK: [fuzz-exec] calling c
35+
;; CHECK-NEXT: [exception thrown: unhandled suspend]
36+
(func $c (export "c")
37+
(suspend $tag)
38+
)
39+
)
40+

0 commit comments

Comments
 (0)