From fed61eb6b8536315261f947a17d5914c3ca32579 Mon Sep 17 00:00:00 2001 From: Aarnav Date: Mon, 15 Jul 2024 15:41:51 +0200 Subject: [PATCH] Fix qemu_launcher by moving stop request handling to fuzz_one (#2394) Co-authored-by: Romain Malmain --- libafl/src/fuzzer/mod.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libafl/src/fuzzer/mod.rs b/libafl/src/fuzzer/mod.rs index d0a2f96873..461f3b07fa 100644 --- a/libafl/src/fuzzer/mod.rs +++ b/libafl/src/fuzzer/mod.rs @@ -212,7 +212,7 @@ pub trait Fuzzer: Sized + UsesState where Self::State: HasMetadata + HasExecutions + HasLastReportTime + Stoppable, E: UsesState, - EM: ProgressReporter + EventProcessor, + EM: ProgressReporter, ST: StagesTuple, { /// Fuzz for a single iteration. @@ -244,14 +244,8 @@ where loop { // log::info!("Starting another fuzz_loop"); manager.maybe_report_progress(state, monitor_timeout)?; - if state.stop_requested() { - state.discard_stop_request(); - manager.on_shutdown()?; - break; - } self.fuzz_one(stages, executor, state, manager)?; } - Ok(()) } /// Fuzz for n iterations. @@ -282,10 +276,6 @@ where for _ in 0..iters { manager.maybe_report_progress(state, monitor_timeout)?; - if state.stop_requested() { - state.discard_stop_request(); - break; - } ret = Some(self.fuzz_one(stages, executor, state, manager)?); } @@ -834,6 +824,12 @@ where state.clear_corpus_id()?; + if state.stop_requested() { + state.discard_stop_request(); + manager.on_shutdown()?; + return Err(Error::shutting_down()) + } + Ok(id) } }