-
-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error handeling in libafl/src/corpus #2990
base: main
Are you sure you want to change the base?
Conversation
i think most of these unwrap() will never happen. |
libafl/src/corpus/cached.rs
Outdated
@@ -38,7 +38,9 @@ where | |||
self.load_input_into(&mut testcase.borrow_mut())?; | |||
let mut borrowed_num = 0; | |||
while self.cached_indexes.borrow().len() >= self.cache_max_len { | |||
let removed = self.cached_indexes.borrow_mut().pop_front().unwrap(); | |||
let removed = self.cached_indexes.borrow_mut().pop_front().ok_or_else(|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will never happen. the thing we really need is to make cache_max_len
to NonZeroUsize
i don't know. the changes here are either correcting unwrap() that either
I perfer for the panic to stay because at least i can see the backtraces. |
Ok so i will can make some unwrap to be as it, and only chnage which are necessary |
see this this is what we really want then panic will never happen from this unwrap() will never happen |
libafl/src/corpus/inmemory.rs
Outdated
if let Some(item) = self.map.remove(&id) { | ||
self.remove_key(id); | ||
if let Some(prev) = item.prev { | ||
self.map.get_mut(&prev).unwrap().next = item.next; | ||
self.map.get_mut(&prev).ok_or_else(|| Error::illegal_state("Unable to fetch previous CorpusId"))?.next = item.next; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next CorpusId
libafl/src/corpus/minimizer.rs
Outdated
@@ -198,7 +198,7 @@ where | |||
let mut removed = Vec::with_capacity(state.corpus().count()); | |||
for (seed, (id, _)) in seed_exprs { | |||
// if the model says the seed isn't there, mark it for deletion | |||
if !model.eval(&seed, true).unwrap().as_bool().unwrap() { | |||
if !model.eval(&seed, true).ok_or_else(|| Error::illegal_state("Error Evaluating Modal"))?.as_bool().ok_or_else(|| Error::illegal_state("Error converting condition to bool"))? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evaluating model
This also needs |
I have done cargo fmt, etc and now no errors are comming |
Changed all .unwrap with appropriate libafl_bolts::Error
#1908