diff options
| author | Kostya Serebryany <kcc@google.com> | 2019-06-14 19:54:32 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2019-06-14 19:54:32 +0000 |
| commit | 3f39123d15ba5e145ce81c63ea7e03c72c3b4f8f (patch) | |
| tree | 13355f64a3aab2b52112bc67f528560aca7a85db /compiler-rt/lib/fuzzer/FuzzerFork.cpp | |
| parent | 1b091540d28e0baea49b21d4ab333b22309b0edb (diff) | |
| download | bcm5719-llvm-3f39123d15ba5e145ce81c63ea7e03c72c3b4f8f.tar.gz bcm5719-llvm-3f39123d15ba5e145ce81c63ea7e03c72c3b4f8f.zip | |
[libFuzzer] simplify the DFT trace collection using the new faster DFSan mode that traces up to 16 labels at a time and never runs out of labels. Second attempt. This time with a fix for windows (putenv instead of setenv))
llvm-svn: 363445
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerFork.cpp')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerFork.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerFork.cpp b/compiler-rt/lib/fuzzer/FuzzerFork.cpp index 870a2244850..5c4855f8284 100644 --- a/compiler-rt/lib/fuzzer/FuzzerFork.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerFork.cpp @@ -89,6 +89,7 @@ struct GlobalEnv { std::string DFTDir; std::string DataFlowBinary; Set<uint32_t> Features, Cov; + Set<std::string> FilesWithDFT; Vector<std::string> Files; Random *Rand; std::chrono::system_clock::time_point ProcessStartTime; @@ -126,10 +127,13 @@ struct GlobalEnv { auto Job = new FuzzJob; std::string Seeds; if (size_t CorpusSubsetSize = - std::min(Files.size(), (size_t)sqrt(Files.size() + 2))) - for (size_t i = 0; i < CorpusSubsetSize; i++) - Seeds += (Seeds.empty() ? "" : ",") + - Files[Rand->SkewTowardsLast(Files.size())]; + std::min(Files.size(), (size_t)sqrt(Files.size() + 2))) { + for (size_t i = 0; i < CorpusSubsetSize; i++) { + auto &SF = Files[Rand->SkewTowardsLast(Files.size())]; + Seeds += (Seeds.empty() ? "" : ",") + SF; + CollectDFT(SF); + } + } if (!Seeds.empty()) { Job->SeedListPath = DirPlusFile(TempDir, std::to_string(JobId) + ".seeds"); @@ -196,7 +200,6 @@ struct GlobalEnv { auto NewPath = DirPlusFile(MainCorpusDir, Hash(U)); WriteToFile(U, NewPath); Files.push_back(NewPath); - CollectDFT(NewPath); } Features.insert(NewFeatures.begin(), NewFeatures.end()); Cov.insert(NewCov.begin(), NewCov.end()); @@ -217,6 +220,7 @@ struct GlobalEnv { void CollectDFT(const std::string &InputPath) { if (DataFlowBinary.empty()) return; + if (!FilesWithDFT.insert(InputPath).second) return; Command Cmd(Args); Cmd.removeFlag("fork"); Cmd.removeFlag("runs"); @@ -226,7 +230,7 @@ struct GlobalEnv { Cmd.removeArgument(C); Cmd.setOutputFile(DirPlusFile(TempDir, "dft.log")); Cmd.combineOutAndErr(); - // Printf("CollectDFT: %s %s\n", InputPath.c_str(), Cmd.toString().c_str()); + // Printf("CollectDFT: %s\n", Cmd.toString().c_str()); ExecuteCommand(Cmd); } @@ -296,9 +300,6 @@ void FuzzWithFork(Random &Rand, const FuzzingOptions &Options, CrashResistantMerge(Env.Args, {}, SeedFiles, &Env.Files, {}, &Env.Features, {}, &Env.Cov, CFPath, false); - for (auto &F : Env.Files) - Env.CollectDFT(F); - RemoveFile(CFPath); Printf("INFO: -fork=%d: %zd seed inputs, starting to fuzz in %s\n", NumJobs, Env.Files.size(), Env.TempDir.c_str()); |

