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); 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/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: llvm/docs/LibFuzzer.rst =================================================================== --- llvm/docs/LibFuzzer.rst +++ llvm/docs/LibFuzzer.rst @@ -305,6 +305,8 @@ If 1, print out newly covered PCs. Defaults to 0. ``-print_final_stats`` If 1, print statistics at exit. Defaults to 0. +``-detect_exits`` + If 1, report when fuzz targets exit. Defaults to 1. ``-detect_leaks`` If 1 (default) and if LeakSanitizer is enabled try to detect memory leaks during fuzzing (i.e. not only at shut down).