#Centipede Locate the crash and report the information before exiting when --exit_on_crash is set.
PiperOrigin-RevId: 547831871
diff --git a/centipede/centipede.cc b/centipede/centipede.cc
index 43414f1..71d37e8 100644
--- a/centipede/centipede.cc
+++ b/centipede/centipede.cc
@@ -318,11 +318,6 @@
ExecuteAndReportCrash(extra_binary, input_vec, extra_batch_result) &&
success;
}
- if (!success && env_.exit_on_crash) {
- LOG(INFO) << "--exit_on_crash is enabled; exiting soon";
- RequestEarlyExit(EXIT_FAILURE);
- return false;
- }
CHECK_EQ(batch_result.results().size(), input_vec.size());
num_runs_ += input_vec.size();
bool batch_gained_new_coverage = false;
@@ -833,6 +828,10 @@
CHECK(file != nullptr) << log_prefix << "Failed to open " << file_path;
RemoteFileAppend(file, one_input);
RemoteFileClose(file);
+ if (env_.exit_on_crash) {
+ LOG(INFO) << "--exit_on_crash is enabled; exiting soon.";
+ RequestEarlyExit(EXIT_FAILURE);
+ }
return;
}
}
diff --git a/fuzztest/BUILD b/fuzztest/BUILD
index 1db39cc..8db2b13 100644
--- a/fuzztest/BUILD
+++ b/fuzztest/BUILD
@@ -103,7 +103,7 @@
":fixture_driver",
":logging",
":runtime",
- "@com_google_absl//absl/strings:str_format",
+ "@com_google_absl//absl/algorithm:container",
"@com_google_fuzztest//centipede:centipede_runner_no_main",
],
)
diff --git a/fuzztest/internal/centipede_adaptor.cc b/fuzztest/internal/centipede_adaptor.cc
index f00295a..47d6927 100644
--- a/fuzztest/internal/centipede_adaptor.cc
+++ b/fuzztest/internal/centipede_adaptor.cc
@@ -25,6 +25,7 @@
#include <utility>
#include <vector>
+#include "absl/algorithm/container.h"
#include "./centipede/runner_interface.h"
#include "./fuzztest/internal/domains/domain_base.h"
#include "./fuzztest/internal/logging.h"
@@ -66,6 +67,21 @@
return false;
}
+ void GetSeeds(
+ std::function<void(centipede::ByteSpan)> seed_callback) override {
+ std::vector<GenericDomainCorpusType> seeds =
+ fuzzer_impl_.fixture_driver_->GetSeeds();
+ absl::c_shuffle(seeds, prng_);
+ if (seeds.empty())
+ seeds.push_back(fuzzer_impl_.params_domain_->UntypedInit(prng_));
+ for (const auto& seed : seeds) {
+ const auto seed_serialized =
+ fuzzer_impl_.params_domain_->UntypedSerializeCorpus(seed).ToString();
+ seed_callback(
+ {(unsigned char*)seed_serialized.data(), seed_serialized.size()});
+ }
+ }
+
bool Mutate(
const std::vector<centipede::MutationInputRef>& inputs,
size_t num_mutants,