[llvm] r286689 - [libFuzzer] use less stack
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 11:31:28 PST 2016
Done, thanks!
r286870.
On Mon, Nov 14, 2016 at 9:34 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> On Fri, Nov 11, 2016 at 4:34 PM Kostya Serebryany via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: kcc
>> Date: Fri Nov 11 18:24:35 2016
>> New Revision: 286689
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=286689&view=rev
>> Log:
>> [libFuzzer] use less stack
>>
>> Added:
>> llvm/trunk/lib/Fuzzer/test/ulimit.test
>> Modified:
>> llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp
>>
>> Modified: llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/
>> FuzzerDriver.cpp?rev=286689&r1=286688&r2=286689&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp (original)
>> +++ llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp Fri Nov 11 18:24:35 2016
>> @@ -446,15 +446,15 @@ int FuzzerDriver(int *argc, char ***argv
>> Printf("INFO: Seed: %u\n", Seed);
>>
>> Random Rand(Seed);
>> - MutationDispatcher MD(Rand, Options);
>> - InputCorpus Corpus(Options.OutputCorpus);
>> - Fuzzer F(Callback, Corpus, MD, Options);
>> + auto MD = new MutationDispatcher(Rand, Options);
>> + auto Corpus = new InputCorpus(Options.OutputCorpus);
>> + auto F = new Fuzzer(Callback, *Corpus, *MD, Options);
>>
>
> Generally it's preferable to use 'auto *' when something's a pointer (
> http://llvm.org/docs/CodingStandards.html#beware-
> unnecessary-copies-with-auto ).
>
>
>>
>> for (auto &U: Dictionary)
>> if (U.size() <= Word::GetMaxSize())
>> - MD.AddWordToManualDictionary(Word(U.data(), U.size()));
>> + MD->AddWordToManualDictionary(Word(U.data(), U.size()));
>>
>> - StartRssThread(&F, Flags.rss_limit_mb);
>> + StartRssThread(F, Flags.rss_limit_mb);
>>
>> // Timer
>> if (Flags.timeout > 0)
>> @@ -468,7 +468,7 @@ int FuzzerDriver(int *argc, char ***argv
>> if (Flags.handle_term) SetSigTermHandler();
>>
>> if (Flags.minimize_crash_internal_step)
>> - return MinimizeCrashInputInternalStep(&F, &Corpus);
>> + return MinimizeCrashInputInternalStep(F, Corpus);
>>
>> if (DoPlainRun) {
>> Options.SaveArtifacts = false;
>> @@ -479,7 +479,7 @@ int FuzzerDriver(int *argc, char ***argv
>> auto StartTime = system_clock::now();
>> Printf("Running: %s\n", Path.c_str());
>> for (int Iter = 0; Iter < Runs; Iter++)
>> - RunOneTest(&F, Path.c_str(), Options.MaxLen);
>> + RunOneTest(F, Path.c_str(), Options.MaxLen);
>> auto StopTime = system_clock::now();
>> auto MS = duration_cast<milliseconds>(StopTime -
>> StartTime).count();
>> Printf("Executed %s in %zd ms\n", Path.c_str(), (long)MS);
>> @@ -488,14 +488,14 @@ int FuzzerDriver(int *argc, char ***argv
>> "*** NOTE: fuzzing was not performed, you have only\n"
>> "*** executed the target code on a fixed set of
>> inputs.\n"
>> "***\n");
>> - F.PrintFinalStats();
>> + F->PrintFinalStats();
>> exit(0);
>> }
>>
>> if (Flags.merge) {
>> if (Options.MaxLen == 0)
>> - F.SetMaxInputLen(kMaxSaneLen);
>> - F.Merge(*Inputs);
>> + F->SetMaxInputLen(kMaxSaneLen);
>> + F->Merge(*Inputs);
>> exit(0);
>> }
>>
>> @@ -512,7 +512,7 @@ int FuzzerDriver(int *argc, char ***argv
>> size_t MaxLen = 0;
>> for (auto &U : InitialCorpus)
>> MaxLen = std::max(U.size(), MaxLen);
>> - F.SetMaxInputLen(std::min(std::max(kMinDefaultLen, MaxLen),
>> kMaxSaneLen));
>> + F->SetMaxInputLen(std::min(std::max(kMinDefaultLen, MaxLen),
>> kMaxSaneLen));
>> }
>>
>> if (InitialCorpus.empty()) {
>> @@ -520,14 +520,14 @@ int FuzzerDriver(int *argc, char ***argv
>> if (Options.Verbosity)
>> Printf("INFO: A corpus is not provided, starting from an empty
>> corpus\n");
>> }
>> - F.ShuffleAndMinimize(&InitialCorpus);
>> + F->ShuffleAndMinimize(&InitialCorpus);
>> InitialCorpus.clear(); // Don't need this memory any more.
>> - F.Loop();
>> + F->Loop();
>>
>> if (Flags.verbosity)
>> - Printf("Done %d runs in %zd second(s)\n", F.getTotalNumberOfRuns(),
>> - F.secondsSinceProcessStartUp());
>> - F.PrintFinalStats();
>> + Printf("Done %d runs in %zd second(s)\n", F->getTotalNumberOfRuns(),
>> + F->secondsSinceProcessStartUp());
>> + F->PrintFinalStats();
>>
>> exit(0); // Don't let F destroy itself.
>> }
>>
>> Added: llvm/trunk/lib/Fuzzer/test/ulimit.test
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/
>> test/ulimit.test?rev=286689&view=auto
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Fuzzer/test/ulimit.test (added)
>> +++ llvm/trunk/lib/Fuzzer/test/ulimit.test Fri Nov 11 18:24:35 2016
>> @@ -0,0 +1,2 @@
>> +RUN: ulimit -s 1000
>> +RUN: LLVMFuzzer-SimpleTest
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161114/d9b6b8e4/attachment.html>
More information about the llvm-commits
mailing list