Skip to content

Commit 8ccb3f6

Browse files
authored
Fuzzer: Emit fewer null descriptors, which trap (#8030)
This was a major source of testcases failing in initialization.
1 parent 0f642f3 commit 8ccb3f6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/tools/fuzzing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ class TranslateToFuzzReader {
487487
// used in a place that will trap on null. For example, the reference of a
488488
// struct.get or array.set would use this.
489489
Expression* makeTrappingRefUse(HeapType type);
490+
Expression* makeTrappingRefUse(Type type);
490491

491492
Expression* buildUnary(const UnaryArgs& args);
492493
Expression* makeUnary(Type type);

src/tools/fuzzing/fuzzing.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3955,7 +3955,7 @@ Expression* TranslateToFuzzReader::makeCompoundRef(Type type) {
39553955
}
39563956
Expression* descriptor = nullptr;
39573957
if (auto descType = heapType.getDescriptorType()) {
3958-
descriptor = make(Type(*descType, Nullable, Exact));
3958+
descriptor = makeTrappingRefUse(Type(*descType, Nullable, Exact));
39593959
}
39603960
return builder.makeStructNew(heapType, values, descriptor);
39613961
}
@@ -4079,13 +4079,17 @@ Expression* TranslateToFuzzReader::makeStringGet(Type type) {
40794079
}
40804080

40814081
Expression* TranslateToFuzzReader::makeTrappingRefUse(HeapType type) {
4082+
return makeTrappingRefUse(Type(type, Nullable));
4083+
}
4084+
4085+
Expression* TranslateToFuzzReader::makeTrappingRefUse(Type type) {
40824086
auto percent = upTo(100);
40834087
// Only give a low probability to emit a nullable reference.
40844088
if (percent < 5) {
4085-
return make(Type(type, Nullable));
4089+
return make(type.with(Nullable));
40864090
}
40874091
// Otherwise, usually emit a non-nullable one.
4088-
auto nonNull = Type(type, NonNullable);
4092+
auto nonNull = type.with(NonNullable);
40894093
if (percent < 70 || !funcContext) {
40904094
return make(nonNull);
40914095
}

0 commit comments

Comments
 (0)