From 0eea9370fa9c98848ff0c538ebdfded70f9abd67 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Thu, 6 Oct 2016 05:14:00 +0000 Subject: [PATCH] [libFuzzer] be more careful with memory usage, print peak rss in status lines llvm-svn: 283418 --- lib/Fuzzer/FuzzerCorpus.h | 2 +- lib/Fuzzer/FuzzerDriver.cpp | 1 + lib/Fuzzer/FuzzerLoop.cpp | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Fuzzer/FuzzerCorpus.h b/lib/Fuzzer/FuzzerCorpus.h index a46f1dccb45..382980b9fee 100644 --- a/lib/Fuzzer/FuzzerCorpus.h +++ b/lib/Fuzzer/FuzzerCorpus.h @@ -123,7 +123,7 @@ class InputCorpus { assert(II.NumFeatures > 0); II.NumFeatures--; if (II.NumFeatures == 0) { - II.U.clear(); + Unit().swap(II.U); if (FeatureDebug) Printf("EVICTED %zd\n", SmallestElementPerFeature[Idx]); } diff --git a/lib/Fuzzer/FuzzerDriver.cpp b/lib/Fuzzer/FuzzerDriver.cpp index fd88d50cfa8..336bdf0f859 100644 --- a/lib/Fuzzer/FuzzerDriver.cpp +++ b/lib/Fuzzer/FuzzerDriver.cpp @@ -516,6 +516,7 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) { Printf("INFO: A corpus is not provided, starting from an empty corpus\n"); } F.ShuffleAndMinimize(&InitialCorpus); + InitialCorpus.clear(); // Don't need this memory any more. F.Loop(); if (Flags.verbosity) diff --git a/lib/Fuzzer/FuzzerLoop.cpp b/lib/Fuzzer/FuzzerLoop.cpp index a1772412a32..49b58ddf5d5 100644 --- a/lib/Fuzzer/FuzzerLoop.cpp +++ b/lib/Fuzzer/FuzzerLoop.cpp @@ -274,7 +274,7 @@ void Fuzzer::RssLimitCallback() { GetPid(), GetPeakRSSMb(), Options.RssLimitMb); Printf(" To change the out-of-memory limit use -rss_limit_mb=\n\n"); if (EF->__sanitizer_print_memory_profile) - EF->__sanitizer_print_memory_profile(50); + EF->__sanitizer_print_memory_profile(95); DumpCurrentUnit("oom-"); Printf("SUMMARY: libFuzzer: out-of-memory\n"); PrintFinalStats(); @@ -324,6 +324,7 @@ void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units) { Printf(" units: %zd", Units); Printf(" exec/s: %zd", ExecPerSec); + Printf(" rss: %zdMb", GetPeakRSSMb()); Printf("%s", End); }