diff --git a/fuzzers/libafl-fuzz/src/fuzzer.rs b/fuzzers/libafl-fuzz/src/fuzzer.rs index 392315bfb7..059919ea14 100644 --- a/fuzzers/libafl-fuzz/src/fuzzer.rs +++ b/fuzzers/libafl-fuzz/src/fuzzer.rs @@ -15,7 +15,10 @@ use libafl::{ scheduled::havoc_mutations, tokens_mutations, AFLppRedQueen, StdScheduledMutator, Tokens, }, observers::{CanTrack, HitcountsMapObserver, StdMapObserver, TimeObserver}, - schedulers::{powersched::PowerSchedule, QueueScheduler, StdWeightedScheduler}, + schedulers::{ + powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, QueueScheduler, + StdWeightedScheduler, + }, stages::{ mutational::MultiMutationalStage, CalibrationStage, ColorizationStage, IfStage, StagesTuple, StdMutationalStage, StdPowerMutationalStage, SyncFromDiskStage, @@ -183,7 +186,10 @@ where weighted_scheduler = weighted_scheduler.cycling_scheduler(); } // TODO: Go back to IndexesLenTimeMinimizerScheduler once AflScheduler is implemented for it. - scheduler = SupportedSchedulers::Weighted(weighted_scheduler, PhantomData); + scheduler = SupportedSchedulers::Weighted( + IndexesLenTimeMinimizerScheduler::new(&edges_observer, weighted_scheduler), + PhantomData, + ); } // Create our Fuzzer diff --git a/fuzzers/libafl-fuzz/src/scheduler.rs b/fuzzers/libafl-fuzz/src/scheduler.rs index 375016dacc..0b5477abb1 100644 --- a/fuzzers/libafl-fuzz/src/scheduler.rs +++ b/fuzzers/libafl-fuzz/src/scheduler.rs @@ -3,29 +3,33 @@ use std::marker::PhantomData; use libafl::{ corpus::{CorpusId, HasTestcase, Testcase}, inputs::UsesInput, - observers::ObserversTuple, - schedulers::{HasQueueCycles, RemovableScheduler, Scheduler}, + observers::{CanTrack, ObserversTuple}, + schedulers::{HasQueueCycles, MinimizerScheduler, RemovableScheduler, Scheduler, TestcaseScore}, state::{HasCorpus, HasRand, State, UsesState}, Error, HasMetadata, }; +use libafl_bolts::{serdeany::SerdeAny, AsIter, HasRefCnt}; -pub enum SupportedSchedulers { - Queue(Q, PhantomData<(S, Q, W)>), - Weighted(W, PhantomData<(S, Q, W)>), +pub enum SupportedSchedulers { + Queue(Q, PhantomData<(S, Q, CS, F, M, O)>), + Weighted(MinimizerScheduler, PhantomData<(S, Q, CS, F, M, O)>), } -impl UsesState for SupportedSchedulers +impl UsesState for SupportedSchedulers where S: State + HasRand + HasCorpus + HasMetadata + HasTestcase, { type State = S; } -impl RemovableScheduler for SupportedSchedulers +impl RemovableScheduler for SupportedSchedulers where S: UsesInput + HasTestcase + HasMetadata + HasCorpus + HasRand + State, Q: Scheduler + RemovableScheduler, - W: Scheduler + RemovableScheduler, + CS: RemovableScheduler, + M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt, + O: CanTrack, + F: TestcaseScore, { fn on_remove( &mut self, @@ -52,11 +56,14 @@ where } } -impl Scheduler for SupportedSchedulers +impl Scheduler for SupportedSchedulers where S: UsesInput + HasTestcase + HasMetadata + HasCorpus + HasRand + State, Q: Scheduler, - W: Scheduler, + CS: Scheduler, + M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt, + O: CanTrack, + F: TestcaseScore { fn on_add(&mut self, state: &mut Self::State, id: CorpusId) -> Result<(), Error> { match self { @@ -99,16 +106,19 @@ where } } -impl HasQueueCycles for SupportedSchedulers +impl HasQueueCycles for SupportedSchedulers where S: UsesInput + HasTestcase + HasMetadata + HasCorpus + HasRand + State, Q: Scheduler + HasQueueCycles, - W: Scheduler + HasQueueCycles, + CS: Scheduler + HasQueueCycles, + O: CanTrack, + M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt, + F: TestcaseScore { fn queue_cycles(&self) -> u64 { match self { Self::Queue(queue, _) => queue.queue_cycles(), - Self::Weighted(weighted, _) => weighted.queue_cycles(), + Self::Weighted(weighted, _) => weighted.base().queue_cycles(), } } }