diff options
author | Matt Morehouse <mascasa@google.com> | 2017-07-20 20:43:39 +0000 |
---|---|---|
committer | Matt Morehouse <mascasa@google.com> | 2017-07-20 20:43:39 +0000 |
commit | 9e689792b23b017507955dba1a0d21b239d4b869 (patch) | |
tree | 4f9c3fb6fa5cdf34aa510b6456939ffed92e3d89 /llvm/lib/Fuzzer/FuzzerLoop.cpp | |
parent | 0c8d26c312f62347e1640384c9a42fce97c2c657 (diff) | |
download | bcm5719-llvm-9e689792b23b017507955dba1a0d21b239d4b869.tar.gz bcm5719-llvm-9e689792b23b017507955dba1a0d21b239d4b869.zip |
Generate error reports when a fuzz target exits.
Summary:
Implements https://github.com/google/sanitizers/issues/835.
Flush stdout before exiting in test cases.
Since the atexit hook is used for exit reports, pending prints to
stdout can be lost if they aren't flushed before calling exit().
Expect tests to have non-zero exit code if exit() is called.
Reviewers: vitalybuka, kcc
Reviewed By: kcc
Subscribers: eraman, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D35602
llvm-svn: 308669
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerLoop.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp index ba4ba80db00..b9e70b6dadd 100644 --- a/llvm/lib/Fuzzer/FuzzerLoop.cpp +++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp @@ -175,6 +175,11 @@ void Fuzzer::StaticCrashSignalCallback() { F->CrashCallback(); } +void Fuzzer::StaticExitCallback() { + assert(F); + F->ExitCallback(); +} + void Fuzzer::StaticInterruptCallback() { assert(F); F->InterruptCallback(); @@ -198,6 +203,19 @@ void Fuzzer::CrashCallback() { _Exit(Options.ErrorExitCode); // Stop right now. } +void Fuzzer::ExitCallback() { + if (!RunningCB) + return; // This exit did not come from the user callback + Printf("==%lu== ERROR: libFuzzer: fuzz target exited\n", GetPid()); + if (EF->__sanitizer_print_stack_trace) + EF->__sanitizer_print_stack_trace(); + Printf("SUMMARY: libFuzzer: fuzz target exited\n"); + DumpCurrentUnit("crash-"); + PrintFinalStats(); + _Exit(Options.ErrorExitCode); +} + + void Fuzzer::InterruptCallback() { Printf("==%lu== libFuzzer: run interrupted; exiting\n", GetPid()); PrintFinalStats(); |