Skip to content

Commit dfd73df

Browse files
committed
Improve efficiency of mutator by allowing Copy/Clone only in CrossOver
That's very libFuzzer specific tweek libFuzzer calls LLVMFuzzerCustomMutator and LLVMFuzzerCustomCrossOver with same probability. However LLVMFuzzerCustomCrossOver is just a variation of Copy/Clone. So before the patch all mutator activity was more skewed toward Copy/Clone. This results in 2x increases in new feature discovery per iteration.
1 parent e635fea commit dfd73df

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/mutator.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,8 @@ bool Mutator::MutateImpl(const ConstMessages& sources, const Messages& messages,
684684
mutations[static_cast<size_t>(Mutation::Delete)] = true;
685685
} else {
686686
mutations.set();
687+
mutations[static_cast<size_t>(Mutation::Copy)] = false;
688+
mutations[static_cast<size_t>(Mutation::Clone)] = false;
687689
}
688690
while (mutations.any()) {
689691
MutationSampler mutation(keep_initialized_, mutations, &random_);

src/mutator_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void MutatorFieldTest::TestCopyField() {
555555
to.add_repeated_msg()->CopyFrom(*m1_);
556556
to.add_repeated_msg()->CopyFrom(*m1_);
557557
to.mutable_repeated_msg(1)->add_repeated_string("repeated_string");
558-
EXPECT_TRUE(Mutate(from, to));
558+
EXPECT_TRUE(CrossOver(from, from, to));
559559
}
560560
}
561561

0 commit comments

Comments
 (0)