[compiler-rt] c7d4921 - [libFuzzer] Pass the current size to Mutate in MinimizeCrashLoop (#223470)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 16:46:52 PDT 2026
Author: Stan Ulbrych
Date: 2026-09-15T16:46:47-07:00
New Revision: c7d4921b39bf5710968872213935198efbb310fd
URL: https://github.com/llvm/llvm-project/commit/c7d4921b39bf5710968872213935198efbb310fd
DIFF: https://github.com/llvm/llvm-project/commit/c7d4921b39bf5710968872213935198efbb310fd.diff
LOG: [libFuzzer] Pass the current size to Mutate in MinimizeCrashLoop (#223470)
Fixes #149942. MinimizeCrashLoop passed U.size() to every MD.Mutate call
in the mutate_depth loop, so following mutations operated on a stale
size. Track the size across mutations, like MutateAndTestOne already
does.
Added:
Modified:
compiler-rt/lib/fuzzer/FuzzerLoop.cpp
compiler-rt/test/fuzzer/minimize_crash_custom_mutator.test
Removed:
################################################################################
diff --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
index 39ccf50c40069..5511dfa8cf268 100644
--- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
@@ -921,14 +921,16 @@ void Fuzzer::MinimizeCrashLoop(const Unit &U) {
return;
while (!TimedOut() && TotalNumberOfRuns < Options.MaxNumberOfRuns) {
MD.StartMutationSequence();
- memcpy(CurrentUnitData, U.data(), U.size());
+ size_t Size = U.size();
+ memcpy(CurrentUnitData, U.data(), Size);
for (int i = 0; i < Options.MutateDepth; i++) {
- size_t NewSize = MD.Mutate(CurrentUnitData, U.size(), MaxMutationLen);
+ size_t NewSize = MD.Mutate(CurrentUnitData, Size, MaxMutationLen);
assert(NewSize > 0 && NewSize <= MaxMutationLen);
ExecuteCallback(CurrentUnitData, NewSize);
PrintPulseAndReportSlowInput(CurrentUnitData, NewSize);
TryDetectingAMemoryLeak(CurrentUnitData, NewSize,
/*DuringInitialCorpusExecution*/ false);
+ Size = NewSize;
}
}
}
diff --git a/compiler-rt/test/fuzzer/minimize_crash_custom_mutator.test b/compiler-rt/test/fuzzer/minimize_crash_custom_mutator.test
index 4450639a8e197..d8ce78b10c0a9 100644
--- a/compiler-rt/test/fuzzer/minimize_crash_custom_mutator.test
+++ b/compiler-rt/test/fuzzer/minimize_crash_custom_mutator.test
@@ -1,4 +1,3 @@
-XFAIL: *
RUN: %cpp_compiler %S/MinimizeCrashCustomMutatorTest.cpp -o %t-MinimizeCrashCustomMutatorTest
RUN: mkdir -p %t.dir
RUN: echo -n '!2345678' > %t.dir/crash
More information about the llvm-commits
mailing list