File tree Expand file tree Collapse file tree 2 files changed +42
-44
lines changed Expand file tree Collapse file tree 2 files changed +42
-44
lines changed Original file line number Diff line number Diff line change @@ -703,14 +703,23 @@ Function* TranslateToFuzzReader::addFunction() {
703
703
704
704
void TranslateToFuzzReader::addHangLimitChecks (Function* func) {
705
705
// loop limit
706
- FindAll<Loop> loops (func->body );
707
- for (auto * loop : loops.list ) {
706
+ for (auto * loop : FindAll<Loop>(func->body ).list ) {
708
707
loop->body =
709
708
builder.makeSequence (makeHangLimitCheck (), loop->body , loop->type );
710
709
}
711
710
// recursion limit
712
711
func->body =
713
712
builder.makeSequence (makeHangLimitCheck (), func->body , func->getResults ());
713
+ // ArrayNew can hang the fuzzer if the array size is massive. This doesn't
714
+ // cause an OOM (which the fuzzer knows how to ignore) but it just works for
715
+ // many seconds on building the array. To avoid that, limit the size with high
716
+ // probability.
717
+ for (auto * arrayNew : FindAll<ArrayNew>(func->body ).list ) {
718
+ if (!oneIn (100 )) {
719
+ arrayNew->size = builder.makeBinary (
720
+ AndInt32, arrayNew->size , builder.makeConst (int32_t (1024 - 1 )));
721
+ }
722
+ }
714
723
}
715
724
716
725
void TranslateToFuzzReader::recombine (Function* func) {
Original file line number Diff line number Diff line change 1
1
total
2
- [exports] : 4
3
- [funcs] : 7
2
+ [exports] : 3
3
+ [funcs] : 11
4
4
[globals] : 16
5
5
[imports] : 5
6
6
[memories] : 1
7
7
[memory-data] : 20
8
- [table-data] : 0
8
+ [table-data] : 2
9
9
[tables] : 1
10
10
[tags] : 0
11
- [total] : 600
12
- [vars] : 17
11
+ [total] : 549
12
+ [vars] : 49
13
+ ArrayCopy : 1
13
14
ArrayFill : 1
14
- ArrayLen : 3
15
- ArrayNew : 12
15
+ ArrayLen : 1
16
+ ArrayNew : 14
16
17
ArrayNewFixed : 2
17
- ArraySet : 2
18
- AtomicCmpxchg : 1
19
- AtomicFence : 1
20
- AtomicNotify : 1
21
- AtomicRMW : 2
22
- Binary : 73
18
+ Binary : 75
23
19
Block : 51
24
- Break : 5
25
- Call : 10
26
- CallRef : 3
27
- Const : 162
28
- DataDrop : 1
29
- Drop : 1
30
- GlobalGet : 21
31
- GlobalSet : 20
32
- I31Get : 1
20
+ Break : 6
21
+ Call : 5
22
+ Const : 136
23
+ Drop : 2
24
+ GlobalGet : 24
25
+ GlobalSet : 24
33
26
I31New : 4
34
- If : 21
35
- Load : 22
36
- LocalGet : 43
37
- LocalSet : 29
38
- Loop : 4
39
- MemoryFill : 1
27
+ If : 16
28
+ Load : 18
29
+ LocalGet : 54
30
+ LocalSet : 31
31
+ Loop : 2
40
32
Nop : 8
41
- RefAs : 5
42
- RefCast : 2
43
- RefEq : 2
44
- RefFunc : 9
45
- RefIsNull : 4
46
- RefNull : 8
47
- RefTest : 2
48
- Return : 6
49
- Select : 2
50
- Store : 2
51
- StructNew : 18
52
- TupleExtract : 2
33
+ RefAs : 3
34
+ RefFunc : 4
35
+ RefNull : 10
36
+ Return : 1
37
+ SIMDExtract : 1
38
+ Select : 1
39
+ StructGet : 2
40
+ StructNew : 16
41
+ TupleExtract : 3
53
42
TupleMake : 4
54
- Unary : 19
55
- Unreachable : 10
43
+ Unary : 17
44
+ Unreachable : 12
You can’t perform that action at this time.
0 commit comments