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

fuzz: Port correctness/cse fuzzer over to libfuzzer #7543

Merged
merged 1 commit into from
May 2, 2023

Conversation

nathaniel-brough
Copy link
Contributor

No description provided.

@steven-johnson steven-johnson merged commit 2945c71 into halide:main May 2, 2023
Copy link
Contributor Author

@nathaniel-brough nathaniel-brough left a comment

Choose a reason for hiding this comment

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

#7546 These all look fine


Expr random_expr(FuzzedDataProvider &fdp, int depth, vector<Expr> &exprs) {
if (depth <= 0) {
return fdp.ConsumeIntegralInRange<int>(-5, 4);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks fine #7546 origional rng() % 10 - 5


if (!exprs.empty() && fdp.ConsumeBool()) {
// Reuse an existing expression
return exprs[fdp.ConsumeIntegralInRange<size_t>(0, exprs.size() - 1)];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks fine, explicitly references size()-1

Copy link
Contributor

Choose a reason for hiding this comment

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

Or better yet, use PickValueInArray()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PickValueInArray doesn't work on vectors... see implementation although this is probably annoying enough that I might just create a PR with the LLVM project.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I see, got it. (Not sure if LLVM change is worth the hassle, I gather that libfuzzer is unmaintained at this point as there are now bigger and better fuzzing engines)

Copy link
Contributor

Choose a reason for hiding this comment

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

(But could always just make a local PickValueInVector() wrapper to use in these tests, nice for clarity)

}

Expr next;
switch (fdp.ConsumeIntegralInRange<int>(0, 8)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the idea is that a value of 8 is intended to hit the default case, we should add a comment to that effect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that's what it looks like, I was mostly just attempting to replicate the original logic but while I'm at it I can probably make this clearer too.

break;
}
default:
next = fdp.ConsumeIntegralInRange<int>(-5, 4);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks ok.

ardier pushed a commit to ardier/Halide-mutation that referenced this pull request Mar 3, 2024
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