From c17799906274d186486d19d6d012db3ea32da7b3 Mon Sep 17 00:00:00 2001 From: Xinhao Yuan Date: Thu, 11 Jun 2026 11:08:34 -0700 Subject: [PATCH] A few NFCs for config querying and crash replaying. * Return a failure instead of check on the serailized config querying status, because bad query status is not a bug in Centipede. * Pick runner mode over the path of replaying in current process, which invokes the Centipede controller - we should not invoke the controller in the runner mode. PiperOrigin-RevId: 930631047 --- centipede/centipede_interface.cc | 6 +++++- fuzztest/internal/centipede_adaptor.cc | 15 +++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/centipede/centipede_interface.cc b/centipede/centipede_interface.cc index 386e9222..0a3917c1 100644 --- a/centipede/centipede_interface.cc +++ b/centipede/centipede_interface.cc @@ -775,7 +775,11 @@ int CentipedeMain(const Environment& env, }(); Environment updated_env = env; if (updated_env.fuzztest_corpus_database.empty()) { - FUZZTEST_CHECK_OK(serialized_target_config.status()); + if (!serialized_target_config.ok()) { + FUZZTEST_LOG(ERROR) << "Failed to get the serialized target config: " + << serialized_target_config.status(); + return EXIT_FAILURE; + } if (!serialized_target_config->empty()) { const auto target_config = fuzztest::internal::Configuration::Deserialize( diff --git a/fuzztest/internal/centipede_adaptor.cc b/fuzztest/internal/centipede_adaptor.cc index bc505a6a..bfd67dc5 100644 --- a/fuzztest/internal/centipede_adaptor.cc +++ b/fuzztest/internal/centipede_adaptor.cc @@ -390,6 +390,8 @@ void InstallCentipedeTerminationHandler() { int RunCentipede(const Environment& env, const std::optional& centipede_command) { + FUZZTEST_CHECK(!IsCentipedeRunner()) + << "Unexpected RunCentipede() in runner mode."; if (Runtime::instance().termination_requested()) { absl::FPrintF(GetStderr(), "Not running Centipede due to termination requested - " @@ -908,11 +910,6 @@ bool CentipedeFuzzerAdaptor::Run(int* argc, char*** argv, RunMode mode, CentipedeSetFailureDescription(std::string{crash_type}.c_str()); }); } - if (!configuration.corpus_database.empty() && - configuration.crashing_input_to_reproduce.has_value() && - configuration.replay_in_single_process) { - return ReplayCrashInSingleProcess(configuration); - } if (runner_mode) { std::optional result; fuzzer_impl_.fixture_driver_->RunFuzzTest([&, this]() { @@ -928,7 +925,13 @@ bool CentipedeFuzzerAdaptor::Run(int* argc, char*** argv, RunMode mode, FUZZTEST_CHECK(result.has_value()) << "No result is set for running fuzz test"; return *result == EXIT_SUCCESS; - } else if (is_running_property_function_in_this_process) { + } + if (!configuration.corpus_database.empty() && + configuration.crashing_input_to_reproduce.has_value() && + configuration.replay_in_single_process) { + return ReplayCrashInSingleProcess(configuration); + } + if (is_running_property_function_in_this_process) { // If `is_running_property_function_in_this_process` holds at this point. We // assume it is for `ReplayInputsIfAvailable` to handle `FUZZTEST_REPLAY` // and `FUZZTEST_MINIMIZE_REPRODUCER`, which Centipede does not support.