From 34b4a6ac1d6931e1b732b9329c9401514f60ce93 Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Fri, 15 Mar 2024 19:19:55 +0100 Subject: [PATCH] Better error message instead of "No entries in corpus" --- libafl/src/schedulers/mod.rs | 2 +- libafl/src/schedulers/powersched.rs | 2 +- libafl/src/schedulers/probabilistic_sampling.rs | 2 +- libafl/src/schedulers/queue.rs | 2 +- libafl/src/schedulers/tuneable.rs | 2 +- libafl/src/schedulers/weighted.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libafl/src/schedulers/mod.rs b/libafl/src/schedulers/mod.rs index 5cc3b35f51..2fdd19de84 100644 --- a/libafl/src/schedulers/mod.rs +++ b/libafl/src/schedulers/mod.rs @@ -300,7 +300,7 @@ where /// Gets the next entry at random fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty("No entries in corpus".to_owned())) + Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned())) } else { let id = random_corpus_id!(state.corpus(), state.rand_mut()); self.set_current_scheduled(state, Some(id))?; diff --git a/libafl/src/schedulers/powersched.rs b/libafl/src/schedulers/powersched.rs index d6d96663f9..a0782faf5a 100644 --- a/libafl/src/schedulers/powersched.rs +++ b/libafl/src/schedulers/powersched.rs @@ -259,7 +259,7 @@ where fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty(String::from("No entries in corpus"))) + Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented."))) } else { let id = match state.corpus().current() { Some(cur) => { diff --git a/libafl/src/schedulers/probabilistic_sampling.rs b/libafl/src/schedulers/probabilistic_sampling.rs index 373aec7c89..d4b5c69ad3 100644 --- a/libafl/src/schedulers/probabilistic_sampling.rs +++ b/libafl/src/schedulers/probabilistic_sampling.rs @@ -158,7 +158,7 @@ where #[allow(clippy::cast_precision_loss)] fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty(String::from("No entries in corpus"))) + Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented."))) } else { let rand_prob: f64 = (state.rand_mut().below(100) as f64) / 100.0; let meta = state.metadata_map().get::().unwrap(); diff --git a/libafl/src/schedulers/queue.rs b/libafl/src/schedulers/queue.rs index 12276f4487..d7cc5d62bf 100644 --- a/libafl/src/schedulers/queue.rs +++ b/libafl/src/schedulers/queue.rs @@ -44,7 +44,7 @@ where /// Gets the next entry in the queue fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty("No entries in corpus".to_owned())) + Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned())) } else { let id = state .corpus() diff --git a/libafl/src/schedulers/tuneable.rs b/libafl/src/schedulers/tuneable.rs index eb6577aaf3..61e25cd81a 100644 --- a/libafl/src/schedulers/tuneable.rs +++ b/libafl/src/schedulers/tuneable.rs @@ -119,7 +119,7 @@ where /// Gets the next entry in the queue fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - return Err(Error::empty("No entries in corpus".to_owned())); + return Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned())); } let id = if let Some(next) = Self::get_next(state) { // next was set diff --git a/libafl/src/schedulers/weighted.rs b/libafl/src/schedulers/weighted.rs index 3aaa46b570..d4e95956e5 100644 --- a/libafl/src/schedulers/weighted.rs +++ b/libafl/src/schedulers/weighted.rs @@ -303,7 +303,7 @@ where fn next(&mut self, state: &mut S) -> Result { let corpus_counts = state.corpus().count(); if corpus_counts == 0 { - Err(Error::empty(String::from("No entries in corpus"))) + Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented."))) } else { let s = random_corpus_id!(state.corpus(), state.rand_mut());