[llvm] r266693 - [libFuzzer] try to print correct time in seconds when reporting a timeout. Don't report timeouts while still loading the corpus.
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 18 15:50:40 PDT 2016
Author: kcc
Date: Mon Apr 18 17:50:39 2016
New Revision: 266693
URL: http://llvm.org/viewvc/llvm-project?rev=266693&view=rev
Log:
[libFuzzer] try to print correct time in seconds when reporting a timeout. Don't report timeouts while still loading the corpus.
Modified:
llvm/trunk/lib/Fuzzer/FuzzerInternal.h
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
llvm/trunk/lib/Fuzzer/test/fuzzer-timeout.test
Modified: llvm/trunk/lib/Fuzzer/FuzzerInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerInternal.h?rev=266693&r1=266692&r2=266693&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerInternal.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerInternal.h Mon Apr 18 17:50:39 2016
@@ -391,8 +391,8 @@ private:
void DumpCurrentUnit(const char *Prefix);
void DeathCallback();
- uint8_t *CurrentUnitData;
- size_t CurrentUnitSize;
+ uint8_t *CurrentUnitData = nullptr;
+ size_t CurrentUnitSize = 0;
size_t TotalNumberOfRuns = 0;
size_t TotalNumberOfExecutedTraceBasedMutations = 0;
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=266693&r1=266692&r2=266693&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Mon Apr 18 17:50:39 2016
@@ -280,7 +280,6 @@ void Fuzzer::ShuffleAndMinimize() {
}
bool Fuzzer::RunOne(const uint8_t *Data, size_t Size) {
- UnitStartTime = system_clock::now();
TotalNumberOfRuns++;
PrepareCoverageBeforeRun();
@@ -312,6 +311,7 @@ void Fuzzer::RunOneAndUpdateCorpus(uint8
}
void Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {
+ UnitStartTime = system_clock::now();
// We copy the contents of Unit into a separate heap buffer
// so that we reliably find buffer overflows in it.
std::unique_ptr<uint8_t[]> DataCopy(new uint8_t[Size]);
@@ -320,10 +320,10 @@ void Fuzzer::ExecuteCallback(const uint8
CurrentUnitData = DataCopy.get();
CurrentUnitSize = Size;
int Res = CB(DataCopy.get(), Size);
+ CurrentUnitSize = 0;
+ CurrentUnitData = nullptr;
(void)Res;
assert(Res == 0);
- CurrentUnitData = nullptr;
- CurrentUnitSize = 0;
}
size_t Fuzzer::RecordBlockCoverage() {
Modified: llvm/trunk/lib/Fuzzer/test/fuzzer-timeout.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/fuzzer-timeout.test?rev=266693&r1=266692&r2=266693&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/fuzzer-timeout.test (original)
+++ llvm/trunk/lib/Fuzzer/test/fuzzer-timeout.test Mon Apr 18 17:50:39 2016
@@ -8,7 +8,7 @@ TimeoutTest: #2
TimeoutTest: SUMMARY: libFuzzer: timeout
RUN: not LLVMFuzzer-TimeoutTest -timeout=1 %S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInputTimeoutTest
-SingleInputTimeoutTest: ALARM: working on the last Unit for
+SingleInputTimeoutTest: ALARM: working on the last Unit for {{[1-3]}} seconds
SingleInputTimeoutTest-NOT: Test unit written to ./timeout-
RUN: LLVMFuzzer-TimeoutTest -timeout=1 -timeout_exitcode=0
More information about the llvm-commits
mailing list