Clean up persistent mode when only loading shards.
The function `Centipede::FuzzingLoop()` has an early return when
`env_.load_shard_only` is true, but in this case it wasn't cleaning up the
persistent mode. This was resulting in unexpected behavior, e.g., binaries
instrumented for coverage collection would sometimes be terminated before
the coverage data had a chance of being collected.
PiperOrigin-RevId: 815984240
diff --git a/centipede/centipede.cc b/centipede/centipede.cc
index 8681cc5..97120d3 100644
--- a/centipede/centipede.cc
+++ b/centipede/centipede.cc
@@ -769,7 +769,11 @@
<< " "
<< "seed: " << env_.seed << "\n\n\n";
- UpdateAndMaybeLogStats("begin-fuzz", 0);
+ if (env_.load_shards_only) {
+ UpdateAndMaybeLogStats("begin-load-shard", 0);
+ } else {
+ UpdateAndMaybeLogStats("begin-fuzz", 0);
+ }
if (env_.full_sync) {
LoadAllShardsInRandomOrder(env_, /*rerun_my_shard=*/true);
@@ -782,7 +786,13 @@
MergeFromOtherCorpus(env_.merge_from, env_.my_shard_index);
}
- if (env_.load_shards_only) return;
+ if (env_.load_shards_only) {
+ if (env_.persistent_mode) {
+ user_callbacks_.CleanUpPersistentMode();
+ }
+ UpdateAndMaybeLogStats("end-load-shard", 0);
+ return;
+ }
auto corpus_path = wd_.CorpusFilePaths().Shard(env_.my_shard_index);
auto corpus_file = DefaultBlobFileWriterFactory(env_.riegeli);
diff --git a/e2e_tests/corpus_database_test.cc b/e2e_tests/corpus_database_test.cc
index 500d09e..c41f7d4 100644
--- a/e2e_tests/corpus_database_test.cc
+++ b/e2e_tests/corpus_database_test.cc
@@ -382,11 +382,11 @@
auto [status, std_out, std_err] = RunBinaryMaybeWithCentipede(
GetCorpusDatabaseTestingBinaryPath(), run_options);
- EXPECT_THAT_LOG(
- std_err,
- AllOf(HasSubstr("Replaying FuzzTest.FailsInTwoWays"),
- HasSubstr("Replaying FuzzTest.FailsWithStackOverflow"),
- HasSubstr("[S0.0] begin-fuzz"), HasSubstr("[S1.0] begin-fuzz")));
+ EXPECT_THAT_LOG(std_err,
+ AllOf(HasSubstr("Replaying FuzzTest.FailsInTwoWays"),
+ HasSubstr("Replaying FuzzTest.FailsWithStackOverflow"),
+ HasSubstr("[S0.0] begin-load-shard"),
+ HasSubstr("[S1.0] begin-load-shard")));
EXPECT_THAT_LOG(std_err,
AllOf(ContainsRegex(
R"re((?s)=== Summary of detected crashes ===