Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzing: Do not emit RefAsNonNull in non-function contexts #7188

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3243,14 +3243,19 @@ Expression* TranslateToFuzzReader::makeCompoundRef(Type type) {
// which is not ideal.
if (type.isNonNullable() && (random.finished() || nesting >= LIMIT)) {
// If we have a function context then we can at least emit a local.get,
// perhaps, which is less bad. Note that we need to check typeLocals
// sometimes, which is less bad. Note that we need to check typeLocals
// manually here to avoid infinite recursion (as makeLocalGet will fall back
// to us, if there is no local).
// TODO: we could also look for locals containing subtypes
if (funcContext && !funcContext->typeLocals[type].empty()) {
return makeLocalGet(type);
if (funcContext) {
if (!funcContext->typeLocals[type].empty()) {
return makeLocalGet(type);
}
// No local, but we are in a function context so RefAsNonNull is valid.
return builder.makeRefAs(RefAsNonNull, builder.makeRefNull(heapType));
}
return builder.makeRefAs(RefAsNonNull, builder.makeRefNull(heapType));
// No function context, so we are in quite the pickle. Continue onwards, as
// we may succeed to emit something more complex (like a struct.new).
}

// When we make children, they must be trivial if we are not in a function
Expand Down
Loading