Skip to content

Commit 5aee947

Browse files
authored
fix an infinite loop in fuzz testcase generation code (#1345)
1 parent 593178a commit 5aee947

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

src/tools/fuzzing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class TranslateToFuzzReader {
409409
// the wasm, so they run everywhere
410410
void addInvocations(Function* func) {
411411
std::vector<Expression*> invocations;
412-
while (oneIn(2)) {
412+
while (oneIn(2) && !finishedInput) {
413413
std::vector<Expression*> args;
414414
for (auto type : func->params) {
415415
args.push_back(makeConst(type));

test/passes/translate-to-fuzz.txt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
(export "func_4" (func $func_4))
2020
(export "func_6" (func $func_6))
2121
(export "func_6_invoker" (func $func_6_invoker))
22-
(export "func_9_invoker" (func $func_9_invoker))
2322
(export "hangLimitInitializer" (func $hangLimitInitializer))
2423
(func $func_0 (; 0 ;) (type $FUNCSIG$i) (result i32)
2524
(local $0 i32)
@@ -1365,29 +1364,12 @@
13651364
)
13661365
)
13671366
)
1368-
(func $func_9_invoker (; 10 ;) (type $FUNCSIG$v)
1369-
(drop
1370-
(call $func_9
1371-
(i32.const -120)
1372-
)
1373-
)
1374-
(drop
1375-
(call $func_9
1376-
(i32.const 11571)
1377-
)
1378-
)
1379-
(drop
1380-
(call $func_9
1381-
(i32.const -1)
1382-
)
1383-
)
1384-
)
1385-
(func $hangLimitInitializer (; 11 ;)
1367+
(func $hangLimitInitializer (; 10 ;)
13861368
(set_global $hangLimit
13871369
(i32.const 10)
13881370
)
13891371
)
1390-
(func $deNan32 (; 12 ;) (param $0 f32) (result f32)
1372+
(func $deNan32 (; 11 ;) (param $0 f32) (result f32)
13911373
(if (result f32)
13921374
(f32.eq
13931375
(get_local $0)
@@ -1397,7 +1379,7 @@
13971379
(f32.const 0)
13981380
)
13991381
)
1400-
(func $deNan64 (; 13 ;) (param $0 f64) (result f64)
1382+
(func $deNan64 (; 12 ;) (param $0 f64) (result f64)
14011383
(if (result f64)
14021384
(f64.eq
14031385
(get_local $0)

0 commit comments

Comments
 (0)