Skip to content

Commit

Permalink
[lib/Fuzzer] more efficient reload logic; also don't spam git too much
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237649 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kcc committed May 19, 2015
1 parent c3ccd67 commit 3b3cbed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions lib/Fuzzer/FuzzerInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <string>
#include <vector>
#include <unordered_set>
#include <set>

#include "FuzzerInterface.h"

Expand Down Expand Up @@ -132,7 +131,7 @@ class Fuzzer {
size_t TotalNumberOfRuns = 0;

std::vector<Unit> Corpus;
std::set<Unit> UnitsAddedAfterInitialLoad;
std::unordered_set<std::string> UnitHashesAddedToCorpus;
std::unordered_set<uintptr_t> FullCoverageSets;
std::unordered_set<uint64_t> CoveragePairs;

Expand Down
14 changes: 9 additions & 5 deletions lib/Fuzzer/FuzzerLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ void Fuzzer::RereadOutputCorpus() {
for (auto &X : AdditionalCorpus) {
if (X.size() > (size_t)Options.MaxLen)
X.resize(Options.MaxLen);
if (UnitsAddedAfterInitialLoad.insert(X).second) {
Corpus.push_back(X);
if (UnitHashesAddedToCorpus.insert(Hash(X)).second) {
CurrentUnit.clear();
CurrentUnit.insert(CurrentUnit.begin(), X.begin(), X.end());
size_t NewCoverage = RunOne(CurrentUnit);
if (NewCoverage && Options.Verbosity >= 1)
PrintStats("RELOAD", NewCoverage);
if (NewCoverage) {
Corpus.push_back(X);
if (Options.Verbosity >= 1)
PrintStats("RELOAD", NewCoverage);
}
}
}
}
Expand Down Expand Up @@ -142,6 +144,8 @@ void Fuzzer::ShuffleAndMinimize() {
}
}
Corpus = NewCorpus;
for (auto &X : Corpus)
UnitHashesAddedToCorpus.insert(Hash(X));
PrintStats("INITED", MaxCov);
}

Expand Down Expand Up @@ -292,7 +296,7 @@ void Fuzzer::SaveCorpus() {
void Fuzzer::ReportNewCoverage(size_t NewCoverage, const Unit &U) {
if (!NewCoverage) return;
Corpus.push_back(U);
UnitsAddedAfterInitialLoad.insert(U);
UnitHashesAddedToCorpus.insert(Hash(U));
PrintStats("NEW ", NewCoverage, "");
if (Options.Verbosity) {
std::cerr << " L: " << U.size();
Expand Down
2 changes: 1 addition & 1 deletion lib/Fuzzer/pull_and_push_fuzz_corpus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cd $1
git add *
git commit -m "fuzz test corpus"
git pull --no-edit
for((attempt=0; attempt<100; attempt++)); do
for((attempt=0; attempt<5; attempt++)); do
echo GIT PUSH $1 ATTEMPT $attempt
if $(git push); then break; fi
git pull --no-edit
Expand Down

0 comments on commit 3b3cbed

Please sign in to comment.