This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] Unstable Edge Handling
AbandonedPublic

Authored by kevinwkt on Jul 3 2018, 3:19 PM.

Details

Reviewers
metzman
Dor1s
Summary

If dump_unstable_coverage.
We use the first CollectFeatures to count how many features there are.

If no new features, CollectFeatures like before.

If there are new coverage, we run CB 2 more times,

We check which edges are unstable per input and we store the least amount of hit counts for each edge.
We then apply these hit counts back to inline8bitcounters so that CollectFeatures can work as intended.

Diff Detail

Event Timeline

kevinwkt created this revision.Jul 3 2018, 3:19 PM

This code seems like an improvement over last time, but I'll make another pass tomorrow morning just to be sure =)
It might be easier to review this if it were diffed against https://reviews.llvm.org/D48150 so that I don't need to see changes that aren't relevant. But don't spend too much time figuring out how to do this.

lib/fuzzer/FuzzerLoop.cpp
492

I think it would be cleaner to have one anonymous function that handles Options.DumpUnstableCoverage rather than having two.

498

I think the body of this else (and that of the if for consistency) should be in curly braces since it is more than a few lines long.
Otherwise it's easy to introduce bugs by adding a statement to the end of the else body not realizing that it won't actually be part of the body.

507

dump_unstable_coveragem -> dump_unstable_coverage
Also, don't break comments at random points.
Unless you are breaking up a comment by lines to improve clarity, it's a good rule of thumb to include as many words on a single line as possible (while keeping the line < 80 chars).
In this case:

// If dump_unstable_coverage and found new features, execute the same input
// two more times to detect unstable edges.

(If my example, is over 80 chars don't copy it directly)

513

Let's put curly braces around this, multiline if-else bodies without braces are a bad idea IMO

514

Does there have to be 3 anonymous functions here? Let's discuss tomorrow how we can make this cleaner.

Dor1s added inline comments.Jul 12 2018, 8:03 PM
lib/fuzzer/FuzzerCorpus.h
240

nit: unnecessary () around the second condition

lib/fuzzer/FuzzerLoop.cpp
492

+1, definitely.

528

I don't think this comment makes sense. The first part just repeats the following if condition, and the second part explains what's going on inside of CheckForUnstableCounters, which is not good. E.g. let's say we start re-running an input 5 times, or come up with a completely different implementation of CheckForUnstableCounters. This comment likely won't be updated and thus will create ambiguity. Just remove it.

lib/fuzzer/FuzzerTracePC.cpp
64

Maybe inverse invert this condition and do return;? Also, shouldn't it be an assert?

The same for other functions below.

kevinwkt abandoned this revision.Jul 23 2018, 5:43 PM
kevinwkt marked an inline comment as done.