diff options
author | Kostya Serebryany <kcc@google.com> | 2016-12-16 22:42:05 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-12-16 22:42:05 +0000 |
commit | be7003f99c778beb4917b0caa19c974b0b5bc6fb (patch) | |
tree | 824540b5bec2d77501b173d3de3720ad94f1ae5a /llvm/lib/Fuzzer/FuzzerLoop.cpp | |
parent | 7972bb7b875b275799b968cb57773aca54ba17fe (diff) | |
download | bcm5719-llvm-be7003f99c778beb4917b0caa19c974b0b5bc6fb.tar.gz bcm5719-llvm-be7003f99c778beb4917b0caa19c974b0b5bc6fb.zip |
[libFuzzer] add an experimental flag -experimental_len_control=1 that sets max_len to 1M and tries to increases the actual max sizes of mutations very gradually. Also remove a bit of dead code
llvm-svn: 289998
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerLoop.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp index f161cc7cda6..c666de8f226 100644 --- a/llvm/lib/Fuzzer/FuzzerLoop.cpp +++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp @@ -697,6 +697,19 @@ void Fuzzer::TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size, } } +static size_t ComputeMutationLen(size_t MaxInputSize, size_t MaxMutationLen, + Random &Rand) { + assert(MaxInputSize <= MaxMutationLen); + if (MaxInputSize == MaxMutationLen) return MaxMutationLen; + size_t Result = MaxInputSize; + size_t R = Rand.Rand(); + if ((R % (1U << 7)) == 0) + Result++; + if ((R % (1U << 15)) == 0) + Result += 10 + Result / 2; + return Min(Result, MaxMutationLen); +} + void Fuzzer::MutateAndTestOne() { MD.StartMutationSequence(); @@ -710,13 +723,19 @@ void Fuzzer::MutateAndTestOne() { assert(MaxMutationLen > 0); + size_t CurrentMaxMutationLen = + Options.ExperimentalLenControl + ? ComputeMutationLen(Corpus.MaxInputSize(), MaxMutationLen, + MD.GetRand()) + : MaxMutationLen; + for (int i = 0; i < Options.MutateDepth; i++) { if (TotalNumberOfRuns >= Options.MaxNumberOfRuns) break; size_t NewSize = 0; - NewSize = MD.Mutate(CurrentUnitData, Size, MaxMutationLen); + NewSize = MD.Mutate(CurrentUnitData, Size, CurrentMaxMutationLen); assert(NewSize > 0 && "Mutator returned empty unit"); - assert(NewSize <= MaxMutationLen && "Mutator return overisized unit"); + assert(NewSize <= CurrentMaxMutationLen && "Mutator return overisized unit"); Size = NewSize; if (i == 0) StartTraceRecording(); |