[llvm] r259731 - [libFuzzer] don't write the test unit when a leak is detected (since we don't know which unit causes the leak)
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 3 16:02:18 PST 2016
Author: kcc
Date: Wed Feb 3 18:02:17 2016
New Revision: 259731
URL: http://llvm.org/viewvc/llvm-project?rev=259731&view=rev
Log:
[libFuzzer] don't write the test unit when a leak is detected (since we don't know which unit causes the leak)
Added:
llvm/trunk/lib/Fuzzer/test/LeakTest.cpp
Modified:
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
llvm/trunk/lib/Fuzzer/test/CMakeLists.txt
llvm/trunk/lib/Fuzzer/test/fuzzer.test
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=259731&r1=259730&r2=259731&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Wed Feb 3 18:02:17 2016
@@ -75,6 +75,7 @@ void Fuzzer::StaticDeathCallback() {
}
void Fuzzer::DeathCallback() {
+ if (!CurrentUnitSize) return;
Printf("DEATH:\n");
if (CurrentUnitSize <= kMaxUnitSizeToPrint) {
PrintHexArray(CurrentUnitData, CurrentUnitSize, "\n");
Modified: llvm/trunk/lib/Fuzzer/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/CMakeLists.txt?rev=259731&r1=259730&r2=259731&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/CMakeLists.txt (original)
+++ llvm/trunk/lib/Fuzzer/test/CMakeLists.txt Wed Feb 3 18:02:17 2016
@@ -20,6 +20,7 @@ set(Tests
FullCoverageSetTest
InitializeTest
MemcmpTest
+ LeakTest
NullDerefTest
RepeatedMemcmp
SimpleCmpTest
Added: llvm/trunk/lib/Fuzzer/test/LeakTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/LeakTest.cpp?rev=259731&view=auto
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/LeakTest.cpp (added)
+++ llvm/trunk/lib/Fuzzer/test/LeakTest.cpp Wed Feb 3 18:02:17 2016
@@ -0,0 +1,11 @@
+// Test with a leak.
+#include <cstdint>
+#include <cstddef>
+
+static volatile void *Sink;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ Sink = new int;
+ return 0;
+}
+
Modified: llvm/trunk/lib/Fuzzer/test/fuzzer.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/fuzzer.test?rev=259731&r1=259730&r2=259731&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/fuzzer.test (original)
+++ llvm/trunk/lib/Fuzzer/test/fuzzer.test Wed Feb 3 18:02:17 2016
@@ -57,3 +57,6 @@ SINGLE_INPUTS: LLVMFuzzer-SimpleTest: Ru
SINGLE_INPUTS: aaa:
SINGLE_INPUTS: bbb:
+RUN: LLVMFuzzer-LeakTest -runs=10 2>&1 | FileCheck %s --check-prefix=LEAK
+LEAK: ERROR: LeakSanitizer: detected memory leaks
+LEAK-NOT: DEATH:
More information about the llvm-commits
mailing list