[PATCH] D39850: [libFuzzer] Don't add leaking inputs to corpus.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 12:44:25 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL317831: [libFuzzer] Don't add leaking inputs to corpus. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D39850?vs=122296&id=122310#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39850

Files:
  compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
  compiler-rt/trunk/test/fuzzer/fuzzer-leak.test


Index: compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
===================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
+++ compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
@@ -641,11 +641,12 @@
     assert(NewSize <= CurrentMaxMutationLen && "Mutator return oversized unit");
     Size = NewSize;
     II.NumExecutedMutations++;
-    if (RunOne(CurrentUnitData, Size, /*MayDeleteFile=*/true, &II))
-      ReportNewCoverage(&II, {CurrentUnitData, CurrentUnitData + Size});
 
+    bool NewCov = RunOne(CurrentUnitData, Size, /*MayDeleteFile=*/true, &II);
     TryDetectingAMemoryLeak(CurrentUnitData, Size,
                             /*DuringInitialCorpusExecution*/ false);
+    if (NewCov)
+      ReportNewCoverage(&II, {CurrentUnitData, CurrentUnitData + Size});
   }
 }
 
Index: compiler-rt/trunk/test/fuzzer/fuzzer-leak.test
===================================================================
--- compiler-rt/trunk/test/fuzzer/fuzzer-leak.test
+++ compiler-rt/trunk/test/fuzzer/fuzzer-leak.test
@@ -3,14 +3,18 @@
 RUN: %cpp_compiler %S/ThreadedLeakTest.cpp -o %t-ThreadedLeakTest
 RUN: %cpp_compiler %S/LeakTimeoutTest.cpp -o %t-LeakTimeoutTest
 
-RUN: not %t-LeakTest -runs=100000 -detect_leaks=1 2>&1 | FileCheck %s --check-prefix=LEAK_DURING
+RUN: rm -rf %t-corpus && mkdir -p %t-corpus
+RUN: not %t-LeakTest -runs=100000 -detect_leaks=1 %t-corpus 2>&1 | FileCheck %s --check-prefix=LEAK_DURING
 LEAK_DURING: ERROR: LeakSanitizer: detected memory leaks
 LEAK_DURING: Direct leak of 4 byte(s) in 1 object(s) allocated from:
 LEAK_DURING: INFO: to ignore leaks on libFuzzer side use -detect_leaks=0
 LEAK_DURING: Test unit written to ./leak-
 LEAK_DURING-NOT: DONE
 LEAK_DURING-NOT: Done
 
+// Verify leaking input was not added to corpus
+RUN: %t-LeakTest -runs=0 %t-corpus
+
 RUN: not %t-LeakTest -runs=0 -detect_leaks=1 %S 2>&1 | FileCheck %s --check-prefix=LEAK_IN_CORPUS
 LEAK_IN_CORPUS: ERROR: LeakSanitizer: detected memory leaks
 LEAK_IN_CORPUS: INFO: a leak has been found in the initial corpus.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39850.122310.patch
Type: text/x-patch
Size: 2054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171109/2a29705e/attachment.bin>


More information about the llvm-commits mailing list