-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
Most MapObservers have an unchangeable initial field #2447
Comments
What's an initial set? The initial value? |
Probably referring to this dude LibAFL/libafl/src/observers/map/mod.rs Line 426 in 76e1b4c
|
Yeah, exactly so. "You cannot set the |
Using something like pub fn set_initial(&mut self, initial: T) {
self.initial = initial;
} If that is the case, can we just add an if self.is_executing {
Err(Error::illegal_state("Cannot update initial value during execution"))
} else {
self.initial = value;
Ok(())
} Please let me know if I oversimplified the issue & there are other factors to consider |
why should it be settable? @addisoncrump |
Potentially (e.g. with min maps) there be other values to which the map is initialised. I haven't encountered this in practice, so in reality this field could probably be removed or made into a const generic.
Rust guarantees that we aren't doubly-mutably accessing, I'm not sure why this would be a concern. |
const generic, yes. |
Sorry if I'm missing something but can't we just do something like: impl<I, S, T, const INITIAL: T> Observer<I, S> for StdMapObserver<'_, T, false, INITIAL>
where
Self: MapObserver,
{
#[inline]
fn pre_exec(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
self.reset_map()
}
} because rust throws an error saying error[E0770]: the type of const parameters must not depend on other generic parameters
--> libafl/src/observers/map/mod.rs:745:28
|
745 | impl<'a, T, const INITIAL: T> StdMapObserver<'a, T, true, INITIAL>
| ^ the type must not depend on the parameter `T`
| So I looked at the way Even though I tried using |
Ahh, this is actually why this was done in the first place, most likely. So there is a legitimate reason. Instead, the |
This limits the relevance of the initial field. We should either make this settable (in constructor or otherwise) or remove the field.
The text was updated successfully, but these errors were encountered: