[compiler-rt] r354191 - [libFuzzer] make len_control less agressive: set the initial max len to the length of the largest seed. This was the original intent, but... Now, with a test, to ensure it stays this way
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 15 17:23:41 PST 2019
Author: kcc
Date: Fri Feb 15 17:23:41 2019
New Revision: 354191
URL: http://llvm.org/viewvc/llvm-project?rev=354191&view=rev
Log:
[libFuzzer] make len_control less agressive: set the initial max len to the length of the largest seed. This was the original intent, but... Now, with a test, to ensure it stays this way
Added:
compiler-rt/trunk/test/fuzzer/len_control.test
Modified:
compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp?rev=354191&r1=354190&r2=354191&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp Fri Feb 15 17:23:41 2019
@@ -153,7 +153,7 @@ Fuzzer::Fuzzer(UserCallback CB, InputCor
if (!Options.OutputCorpus.empty() && Options.ReloadIntervalSec)
EpochOfLastReadOfOutputCorpus = GetEpoch(Options.OutputCorpus);
MaxInputLen = MaxMutationLen = Options.MaxLen;
- TmpMaxMutationLen = Max(size_t(4), Corpus.MaxInputSize());
+ TmpMaxMutationLen = 0; // Will be set once we load the corpus.
AllocateCurrentUnitData();
CurrentUnitSize = 0;
memset(BaseSha1, 0, sizeof(BaseSha1));
@@ -781,6 +781,10 @@ void Fuzzer::Loop(const Vector<std::stri
TPC.SetPrintNewPCs(Options.PrintNewCovPcs);
TPC.SetPrintNewFuncs(Options.PrintNewCovFuncs);
system_clock::time_point LastCorpusReload = system_clock::now();
+
+ TmpMaxMutationLen =
+ Min(MaxMutationLen, Max(size_t(4), Corpus.MaxInputSize()));
+
while (true) {
auto Now = system_clock::now();
if (duration_cast<seconds>(Now - LastCorpusReload).count() >=
Added: compiler-rt/trunk/test/fuzzer/len_control.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/len_control.test?rev=354191&view=auto
==============================================================================
--- compiler-rt/trunk/test/fuzzer/len_control.test (added)
+++ compiler-rt/trunk/test/fuzzer/len_control.test Fri Feb 15 17:23:41 2019
@@ -0,0 +1,11 @@
+# Tests len_control
+RUN: %cpp_compiler %S/SimpleTest.cpp -o %t-SimpleTest
+
+LIM4: DONE{{.*}}lim: 4
+LIM77: DONE{{.*}}lim: 77
+LIM20: DONE{{.*}}lim: 20
+RUN: %run %t-SimpleTest -runs=1 2>&1 | FileCheck %s --check-prefix=LIM4
+RUN: %run %t-SimpleTest -seed_inputs=%t-SimpleTest -max_len=77 -runs=1 2>&1 | FileCheck %s --check-prefix=LIM77
+RUN: echo -n 01234567890123456789 > %t-temp
+RUN: %run %t-SimpleTest -seed_inputs=%t-temp -runs=1 2>&1 | FileCheck %s --check-prefix=LIM20
+
More information about the llvm-commits
mailing list