AFLplusplus / LibAFL

Advanced Fuzzing Library - Slot your Fuzzer together in Rust! Scales across cores and machines. For Windows, Android, MacOS, Linux, no_std, ...
Other
2.03k stars 319 forks source link

Any reason StdMapObserver has to take a static map? #1180

Closed wtdcode closed 1 year ago

wtdcode commented 1 year ago
#[derive(Clone, Serialize, Deserialize, Debug)]
#[serde(bound = "T: serde::de::DeserializeOwned")]
#[allow(clippy::unsafe_derive_deserialize)]
pub struct StdMapObserver<'a, T, const DIFFERENTIAL: bool>
where
    T: Default + Copy + 'static + Serialize,
{
    map: OwnedMutSlice<'a, T>,
    initial: T,
    name: String,
}

I doubt why 'static is required for T here?

domenukk commented 1 year ago

CC @andreafioraldi I think it might be enough to be 'a here?

andreafioraldi commented 1 year ago

no, deserializeowned requires 'static

wtdcode commented 1 year ago

no, deserializeowned requires 'static

@andreafioraldi Reading from https://serde.rs/lifetimes.html , I assume using 'static everywhere is not correct pattern?

andreafioraldi commented 1 year ago

no, deserializeowned requires 'static

@andreafioraldi Reading from https://serde.rs/lifetimes.html , I assume using 'static everywhere is not correct pattern?

That's true for the struct, but StdMapObserver can take non static maps (https://github.com/AFLplusplus/LibAFL/blob/main/libafl/src/observers/map.rs#L544) it is just the type inside the map that must be 'static (integers are in the case of an AFL-like map).

Btw try to remove 'static and see what happens.

domenukk commented 1 year ago

Please reopen if there are further questions or suggestions :)