[libFuzzer] Don't count leak-verification re-executions towards `-runs` (#221036) Fixes #66331. Stop countring the verification run in TryDetectingAMemoryLeak() as part of TotalNumberOfRuns, as the number of executed units could exceed -runs=N. GitOrigin-RevId: 3ff11b27bbd8eca219dab55e9589fcf6a76a79cb
diff --git a/FuzzerLoop.cpp b/FuzzerLoop.cpp index d8e6379..084f91d 100644 --- a/FuzzerLoop.cpp +++ b/FuzzerLoop.cpp
@@ -683,9 +683,6 @@ return; // mallocs==frees, a leak is unlikely. if (!Options.DetectLeaks) return; - if (!DuringInitialCorpusExecution && - TotalNumberOfRuns >= Options.MaxNumberOfRuns) - return; if (!&(EF->__lsan_enable) || !&(EF->__lsan_disable) || !(EF->__lsan_do_recoverable_leak_check)) return; // No lsan. @@ -694,6 +691,10 @@ EF->__lsan_disable(); ExecuteCallback(Data, Size); EF->__lsan_enable(); + // The above is a verification run, and not a fuzzing run, without the + // correction the number of runs would exceed -runs. + // See https://github.com/llvm/llvm-project/issues/66331 + TotalNumberOfRuns--; if (!HasMoreMallocsThanFrees) return; // a leak is unlikely. if (NumberOfLeakDetectionAttempts++ > 1000) {