summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-04-18 22:50:39 +0000
committerKostya Serebryany <kcc@google.com>2016-04-18 22:50:39 +0000
commitebb932d0607bd79fa63e0eddd2e014243e756949 (patch)
tree8453f27adce30aa56800a70af94fee736f475a2c
parent43d1e453479fe60046c06c83c7020a2a52ce9748 (diff)
downloadbcm5719-llvm-ebb932d0607bd79fa63e0eddd2e014243e756949.tar.gz
bcm5719-llvm-ebb932d0607bd79fa63e0eddd2e014243e756949.zip
[libFuzzer] try to print correct time in seconds when reporting a timeout. Don't report timeouts while still loading the corpus.
llvm-svn: 266693
-rw-r--r--llvm/lib/Fuzzer/FuzzerInternal.h4
-rw-r--r--llvm/lib/Fuzzer/FuzzerLoop.cpp6
-rw-r--r--llvm/lib/Fuzzer/test/fuzzer-timeout.test2
3 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerInternal.h b/llvm/lib/Fuzzer/FuzzerInternal.h
index 7200cbe9d3d..50402f8702f 100644
--- a/llvm/lib/Fuzzer/FuzzerInternal.h
+++ b/llvm/lib/Fuzzer/FuzzerInternal.h
@@ -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;
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp
index afdc9fa8540..3b00e47d233 100644
--- a/llvm/lib/Fuzzer/FuzzerLoop.cpp
+++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp
@@ -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_t *Data, size_t Size) {
}
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_t *Data, size_t Size) {
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() {
diff --git a/llvm/lib/Fuzzer/test/fuzzer-timeout.test b/llvm/lib/Fuzzer/test/fuzzer-timeout.test
index 2defef6ac7d..8e8b713fcd7 100644
--- a/llvm/lib/Fuzzer/test/fuzzer-timeout.test
+++ b/llvm/lib/Fuzzer/test/fuzzer-timeout.test
@@ -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
OpenPOWER on IntegriCloud