[libFuzzer] print a visible message if merge fails due to a crash

llvm-svn: 281122
This commit is contained in:
Kostya Serebryany 2016-09-10 00:15:41 +00:00
parent fcdb1af655
commit b991cc1f0e
3 changed files with 24 additions and 0 deletions

View File

@ -521,6 +521,8 @@ private:
// Need to know our own thread.
static thread_local bool IsMyThread;
bool InMergeMode = false;
};
// Global interface to functions that may or may not be available.

View File

@ -188,7 +188,22 @@ void Fuzzer::StaticDeathCallback() {
F->DeathCallback();
}
static void WarnOnUnsuccessfullMerge(bool DoWarn) {
Printf(
"***\n"
"***\n"
"***\n"
"*** NOTE: merge did not succeed due to a failure on one of the inputs.\n"
"*** You will need to filter out crashes from the corpus, e.g. like this:\n"
"*** for f in WITH_CRASHES/*; do ./fuzzer $f && cp $f NO_CRASHES; done\n"
"*** Future versions may have crash-resistant merge, stay tuned.\n"
"***\n"
"***\n"
"***\n");
}
void Fuzzer::DumpCurrentUnit(const char *Prefix) {
WarnOnUnsuccessfullMerge(InMergeMode);
if (!CurrentUnitData) return; // Happens when running individual inputs.
MD.PrintMutationSequence();
Printf("; base unit: %s\n", Sha1ToString(BaseSha1).c_str());
@ -612,6 +627,7 @@ void Fuzzer::Merge(const std::vector<std::string> &Corpora) {
Printf("Merge requires two or more corpus dirs\n");
return;
}
InMergeMode = true;
std::vector<std::string> ExtraCorpora(Corpora.begin() + 1, Corpora.end());
assert(Options.MaxLen > 0);

View File

@ -28,3 +28,9 @@ CHECK2: === Merge: written 3 units
RUN: LLVMFuzzer-FullCoverageSetTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=CHECK3
CHECK3: === Minimizing the initial corpus of 6 units
CHECK3: === Merge: written 0 units
# Check that when merge fails we print an error message.
RUN: echo 'Hi!' > %tmp/T1/HiI
RUN: not LLVMFuzzer-NullDerefTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=MERGE_FAIL
MERGE_FAIL: NOTE: merge did not succeed due to a failure on one of the inputs.