Skip to content

Commit

Permalink
Check domain setup in Execute() to simplify the failure model.
Browse files Browse the repository at this point in the history
For example, we wouldn't want dumping seeds and configurations to fail because of this.

PiperOrigin-RevId: 707222087
  • Loading branch information
xinhaoyuan authored and copybara-github committed Dec 18, 2024
1 parent 3b4a590 commit d385e98
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fuzztest/internal/centipede_adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ class CentipedeAdaptorRunnerCallbacks : public centipede::RunnerCallbacks {
prng_(GetRandomSeed()) {}

bool Execute(centipede::ByteSpan input) override {
if (!domain_setup_is_checked_) {
// Create a new domain input to trigger any domain setup
// failures here. (e.g. Ineffective Filter)
fuzzer_impl_.params_domain_.Init(prng_);
domain_setup_is_checked_ = true;
}

auto parsed_input =
fuzzer_impl_.TryParse({(char*)input.data(), input.size()});
if (parsed_input.ok()) {
Expand Down Expand Up @@ -300,6 +307,7 @@ class CentipedeAdaptorRunnerCallbacks : public centipede::RunnerCallbacks {
Runtime& runtime_;
FuzzTestFuzzerImpl& fuzzer_impl_;
const Configuration& configuration_;
bool domain_setup_is_checked_ = false;
std::unique_ptr<TablesOfRecentCompares> cmp_tables_;
absl::BitGen prng_;
};
Expand Down Expand Up @@ -535,10 +543,6 @@ int CentipedeFuzzerAdaptor::RunInFuzzingMode(
if (IsSilenceTargetEnabled()) SilenceTargetStdoutAndStderr();
runtime_.EnableReporter(&fuzzer_impl_.stats_, [] { return absl::Now(); });
fuzzer_impl_.fixture_driver_->SetUpFuzzTest();
// Always create a new domain input to trigger any domain setup
// failures here. (e.g. Ineffective Filter)
FuzzTestFuzzerImpl::PRNG prng;
fuzzer_impl_.params_domain_.Init(prng);
bool print_final_stats = true;
// When the CENTIPEDE_RUNNER_FLAGS env var exists, the current process is
// considered a child process spawned by the Centipede binary as the runner,
Expand Down

0 comments on commit d385e98

Please sign in to comment.