forked from OSchip/llvm-project
[libFuzzer] print a visible message if merge fails due to a crash
llvm-svn: 281122
This commit is contained in:
parent
fcdb1af655
commit
b991cc1f0e
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue