[PATCH] D45730: [libFuzzer] Add -detect_exits flag.
Matt Morehouse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 17 11:42:36 PDT 2018
morehouse created this revision.
morehouse added reviewers: kcc, vitalybuka.
Allows users to disable exit reports. Motivated by
https://github.com/google/oss-fuzz/pull/1314.
https://reviews.llvm.org/D45730
Files:
compiler-rt/lib/fuzzer/FuzzerDriver.cpp
compiler-rt/lib/fuzzer/FuzzerFlags.def
compiler-rt/test/fuzzer/exit-report.test
Index: compiler-rt/test/fuzzer/exit-report.test
===================================================================
--- compiler-rt/test/fuzzer/exit-report.test
+++ compiler-rt/test/fuzzer/exit-report.test
@@ -1,6 +1,11 @@
RUN: %cpp_compiler %S/SimpleTest.cpp -o %t-SimpleTest
-RUN: not %t-SimpleTest 2>&1 | FileCheck %s
+RUN: not %t-SimpleTest -detect_exits=1 2>&1 | FileCheck %s --check-prefix=REPORT
+RUN: %t-SimpleTest -detect_exits=0 2>&1 | FileCheck %s --check-prefix=NO_REPORT
-CHECK: ERROR: libFuzzer: fuzz target exited
-CHECK: SUMMARY: libFuzzer: fuzz target exited
-CHECK: Test unit written to
+REPORT: ERROR: libFuzzer: fuzz target exited
+REPORT: SUMMARY: libFuzzer: fuzz target exited
+REPORT: Test unit written to
+
+NO_REPORT-NOT: ERROR: libFuzzer: fuzz target exited
+NO_REPORT-NOT: SUMMARY: libFuzzer: fuzz target exited
+NO_REPORT-NOT: Test unit written to
Index: compiler-rt/lib/fuzzer/FuzzerFlags.def
===================================================================
--- compiler-rt/lib/fuzzer/FuzzerFlags.def
+++ compiler-rt/lib/fuzzer/FuzzerFlags.def
@@ -123,6 +123,7 @@
FUZZER_FLAG_INT(close_fd_mask, 0, "If 1, close stdout at startup; "
"if 2, close stderr; if 3, close both. "
"Be careful, this will also close e.g. stderr of asan.")
+FUZZER_FLAG_INT(detect_exits, 1, "If 1, report when fuzz targets exit.")
FUZZER_FLAG_INT(detect_leaks, 1, "If 1, and if LeakSanitizer is enabled "
"try to detect memory leaks during fuzzing (i.e. not only at shut down).")
FUZZER_FLAG_INT(purge_allocator_interval, 1, "Purge allocator caches and "
Index: compiler-rt/lib/fuzzer/FuzzerDriver.cpp
===================================================================
--- compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -654,7 +654,8 @@
Options.HandleUsr2 = Flags.handle_usr2;
SetSignalHandler(Options);
- std::atexit(Fuzzer::StaticExitCallback);
+ if (Flags.detect_exits)
+ std::atexit(Fuzzer::StaticExitCallback);
if (Flags.minimize_crash)
return MinimizeCrashInput(Args, Options);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45730.142806.patch
Type: text/x-patch
Size: 2074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180417/9b95f99f/attachment.bin>
More information about the llvm-commits
mailing list