diff options
| author | Kostya Serebryany <kcc@google.com> | 2019-02-12 02:18:53 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2019-02-12 02:18:53 +0000 |
| commit | cdbb9dc9625a8ce14cb0841a4aab613b0ead23d1 (patch) | |
| tree | 7814f131702cdade0fdf2a7cbfaeae0ea9b6dcfa /compiler-rt/lib/fuzzer | |
| parent | cfc512ab44e20049b82e7cc61102db88f91ccc93 (diff) | |
| download | bcm5719-llvm-cdbb9dc9625a8ce14cb0841a4aab613b0ead23d1.tar.gz bcm5719-llvm-cdbb9dc9625a8ce14cb0841a4aab613b0ead23d1.zip | |
[libFuzzer] teach the fork mode to ignore OOMs and timeouts
llvm-svn: 353792
Diffstat (limited to 'compiler-rt/lib/fuzzer')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerDriver.cpp | 8 | ||||
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerFlags.def | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerMerge.cpp | 6 | ||||
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerOptions.h | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp index 232b3a8732a..8ad99d0a3c2 100644 --- a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp @@ -533,6 +533,12 @@ void FuzzWithFork(Fuzzer *F, const FuzzingOptions &Options, Printf("INFO: temp_files: %zd files_added: %zd newft: %zd ft: %zd\n", TempFiles.size(), FilesToAdd.size(), NewFeatures.size(), Features.size()); + // Continue if our crash is one of the ignorred ones. + if (Options.IgnoreTimeouts && ExitCode == Options.TimeoutExitCode) + continue; + if (Options.IgnoreOOMs && ExitCode == Options.OOMExitCode) + continue; + // And exit if we don't ignore this crash. if (ExitCode != 0) break; } @@ -681,6 +687,8 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) { Options.UnitTimeoutSec = Flags.timeout; Options.ErrorExitCode = Flags.error_exitcode; Options.TimeoutExitCode = Flags.timeout_exitcode; + Options.IgnoreTimeouts = Flags.ignore_timeouts; + Options.IgnoreOOMs = Flags.ignore_ooms; Options.MaxTotalTimeSec = Flags.max_total_time; Options.DoCrossOver = Flags.cross_over; Options.MutateDepth = Flags.mutate_depth; diff --git a/compiler-rt/lib/fuzzer/FuzzerFlags.def b/compiler-rt/lib/fuzzer/FuzzerFlags.def index caf541be820..d194a894f94 100644 --- a/compiler-rt/lib/fuzzer/FuzzerFlags.def +++ b/compiler-rt/lib/fuzzer/FuzzerFlags.def @@ -43,6 +43,8 @@ FUZZER_FLAG_INT(max_total_time, 0, "If positive, indicates the maximal total " FUZZER_FLAG_INT(help, 0, "Print help.") FUZZER_FLAG_INT(fork, 0, "Experimental mode where fuzzing happens " "in a subprocess") +FUZZER_FLAG_INT(ignore_timeouts, 1, "Ignore timeouts in fork mode") +FUZZER_FLAG_INT(ignore_ooms, 1, "Ignore OOMs in fork mode") FUZZER_FLAG_INT(merge, 0, "If 1, the 2-nd, 3-rd, etc corpora will be " "merged into the 1-st corpus. Only interesting units will be taken. " "This flag can be used to minimize a corpus.") diff --git a/compiler-rt/lib/fuzzer/FuzzerMerge.cpp b/compiler-rt/lib/fuzzer/FuzzerMerge.cpp index 4d00f7ed905..c61169a3ae8 100644 --- a/compiler-rt/lib/fuzzer/FuzzerMerge.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerMerge.cpp @@ -299,7 +299,6 @@ void CrashResistantMerge(const Vector<std::string> &Args, Command BaseCmd(Args); BaseCmd.removeFlag("merge"); BaseCmd.removeFlag("fork"); - bool Success = false; for (size_t Attempt = 1; Attempt <= NumAttempts; Attempt++) { Fuzzer::MaybeExitGracefully(); Printf("MERGE-OUTER: attempt %zd\n", Attempt); @@ -309,14 +308,9 @@ void CrashResistantMerge(const Vector<std::string> &Args, auto ExitCode = ExecuteCommand(Cmd); if (!ExitCode) { Printf("MERGE-OUTER: succesfull in %zd attempt(s)\n", Attempt); - Success = true; break; } } - if (!Success) { - Printf("MERGE-OUTER: zero succesfull attempts, exiting\n"); - exit(1); - } // Read the control file and do the merge. Merger M; std::ifstream IF(CFPath); diff --git a/compiler-rt/lib/fuzzer/FuzzerOptions.h b/compiler-rt/lib/fuzzer/FuzzerOptions.h index 868327d58d0..628603ff520 100644 --- a/compiler-rt/lib/fuzzer/FuzzerOptions.h +++ b/compiler-rt/lib/fuzzer/FuzzerOptions.h @@ -23,6 +23,8 @@ struct FuzzingOptions { int OOMExitCode = 71; int InterruptExitCode = 72; int ErrorExitCode = 77; + bool IgnoreTimeouts = 1; + bool IgnoreOOMs = 1; int MaxTotalTimeSec = 0; int RssLimitMb = 0; int MallocLimitMb = 0; |

