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

Fuzzer: Log locals and values referred to from locals #6913

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kripken
Copy link
Member

@kripken kripken commented Sep 6, 2024

Logging values is important in the fuzzer as the loggings are observable
effects that we can then compare to other VMs and after optimizations.
Previously we logged random things, which had some chance to pick
useful data, but it makes sense to focus on sensitive values such as locals.
By logging locals, we get a higher chance to notice when a bad change to a
local happens.

If the local is a reference then we can't log its value, but we can log if it is
null at least. We can also try to find a field that is loggable, if it is a reference
to a struct.

@kripken kripken requested a review from tlively September 6, 2024 22:58
return makeLoggingCall(builder.makeLocalGet(index, type));
}

if (type.isRef()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about inverting this condition to save a level of nesting on most of the following code?

auto& fields = heapType.getStruct().fields;
if (!fields.empty()) {
auto fieldIndex = upTo(fields.size());
auto fieldType = fields[fieldIndex].type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth linearly searching from this random starting index looking for the first loggable field? We could also do a breadth-first search on the type graph looking for a loggable type.

Comment on lines +748 to +752
// If the ref is null, log a random integer. The randomness is to
// avoid the risk of colliding with the value logged in the other
// arm.
auto* whenNull = makeLoggingCall(makeConst(Type::i32));
return builder.makeIf(isNullCheck, whenNull, whenNonNull);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also unconditionally log the result of the null check, followed by a conditional log of the field without an else arm in the if.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants