Skip to content

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

Merged
steven-johnson merged 1 commit intohalide:mainfrom
nathaniel-brough:fuzz_cse
May 2, 2023
Merged

fuzz: Port correctness/cse fuzzer over to libfuzzer#7543
steven-johnson merged 1 commit intohalide:mainfrom
nathaniel-brough:fuzz_cse

Conversation

@nathaniel-brough
Copy link
Copy Markdown
Contributor

No description provided.

@steven-johnson steven-johnson merged commit 2945c71 into halide:main May 2, 2023
Copy link
Copy Markdown
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

Comment thread test/fuzz/cse.cpp

Expr random_expr(FuzzedDataProvider &fdp, int depth, vector<Expr> &exprs) {
if (depth <= 0) {
return fdp.ConsumeIntegralInRange<int>(-5, 4);
Copy link
Copy Markdown
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

Comment thread test/fuzz/cse.cpp

if (!exprs.empty() && fdp.ConsumeBool()) {
// Reuse an existing expression
return exprs[fdp.ConsumeIntegralInRange<size_t>(0, exprs.size() - 1)];
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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)

Comment thread test/fuzz/cse.cpp
}

Expr next;
switch (fdp.ConsumeIntegralInRange<int>(0, 8)) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread test/fuzz/cse.cpp
break;
}
default:
next = fdp.ConsumeIntegralInRange<int>(-5, 4);
Copy link
Copy Markdown
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