Skip to content

Commit

Permalink
Fix qemu_launcher by moving stop request handling to fuzz_one (AFLplu…
Browse files Browse the repository at this point in the history
…splus#2394)

Co-authored-by: Romain Malmain <[email protected]>
  • Loading branch information
R9295 and rmalmain authored Jul 15, 2024
1 parent ea3e70b commit fed61eb
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions libafl/src/fuzzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub trait Fuzzer<E, EM, ST>: Sized + UsesState
where
Self::State: HasMetadata + HasExecutions + HasLastReportTime + Stoppable,
E: UsesState<State = Self::State>,
EM: ProgressReporter<State = Self::State> + EventProcessor<E, Self>,
EM: ProgressReporter<State = Self::State>,
ST: StagesTuple<E, EM, Self::State, Self>,
{
/// Fuzz for a single iteration.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)?);
}

Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit fed61eb

Please sign in to comment.