libafl_bolts: rands super mega ultra giga house cleaning of doom (#2123)

* rands: simpler rand_trait code, remove useless test

* rands: provide and use proper random_seed()

* rands: add missing golden tests

* Don't use current_nanos() for seeding

* rands: remove RandomSeed trait
This commit is contained in:
Gregory Petrosyan 2024-04-29 18:00:44 +03:00 committed by GitHub
parent 50f14d44fa
commit b49ab999e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
59 changed files with 226 additions and 220 deletions

View File

@ -15,7 +15,7 @@ use libafl::{
schedulers::QueueScheduler,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
/* ANCHOR_END: use */
fn main() {
@ -40,7 +40,7 @@ fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),
@ -71,13 +71,7 @@ fn main() {
/* ANCHOR: executor */
// Create the executor for an in-process function
let mut executor = InProcessExecutor::new(
&mut harness,
(),
&mut fuzzer,
&mut state,
&mut mgr,
)
let mut executor = InProcessExecutor::new(&mut harness, (), &mut fuzzer, &mut state, &mut mgr)
.expect("Failed to create the Executor");
/* ANCHOR_END: executor */

View File

@ -15,7 +15,7 @@ use libafl::{
schedulers::QueueScheduler,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
use std::path::PathBuf;
/* ANCHOR_END: use */
@ -65,7 +65,7 @@ fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -17,7 +17,7 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
use std::path::PathBuf;
/* ANCHOR_END: use */
@ -62,7 +62,7 @@ fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -24,7 +24,7 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list};
use libafl_bolts::{rands::StdRand, tuples::tuple_list};
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
@ -69,7 +69,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -21,7 +21,7 @@ use libafl::{
state::StdState,
HasMetadata,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
@ -95,7 +95,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -55,7 +55,7 @@ pub fn main() -> Result<(), Error> {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),
@ -108,7 +108,7 @@ pub fn main() -> Result<(), Error> {
let minimized_dir = PathBuf::from("./minimized");
let mut state = StdState::new(
StdRand::with_seed(current_nanos()),
StdRand::new(),
InMemoryOnDiskCorpus::new(minimized_dir).unwrap(),
InMemoryCorpus::new(),
&mut (),

View File

@ -21,7 +21,7 @@ use libafl::{
state::StdState,
Evaluator,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 128] = [0; 128];
@ -100,7 +100,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -21,7 +21,7 @@ use libafl::{
state::StdState,
HasMetadata,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list};
use libafl_bolts::{rands::StdRand, tuples::tuple_list};
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
@ -62,7 +62,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -23,7 +23,7 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::{HasSolutions, StdState},
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_targets::{edges_max_num, DifferentialAFLMapSwapObserver};
#[cfg(not(miri))]
use mimalloc::MiMalloc;
@ -186,7 +186,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -16,7 +16,7 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list};
use libafl_bolts::{rands::StdRand, tuples::tuple_list};
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
@ -78,7 +78,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -20,7 +20,7 @@ use libafl::{
state::StdState,
Evaluator,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 64] = [0; 64];
@ -67,7 +67,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -15,9 +15,7 @@ use libafl::{
state::{HasSolutions, StdState},
Fuzzer, StdFuzzer,
};
use libafl_bolts::{
current_nanos, rands::StdRand, serdeany::RegistryBuilder, tuples::tuple_list, AsSlice,
};
use libafl_bolts::{rands::StdRand, serdeany::RegistryBuilder, tuples::tuple_list, AsSlice};
use wasm_bindgen::prelude::*;
use web_sys::{Performance, Window};
@ -89,7 +87,7 @@ pub fn fuzz() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// In a "real" fuzzing campaign, you should stash solutions in a JS array instead

View File

@ -18,7 +18,6 @@ use libafl::{
state::StdState,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
shmem::{unix_shmem, ShMemProvider},
tuples::tuple_list,
@ -76,7 +75,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -25,7 +25,7 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
#[cfg(any(windows, unix))]
use libc::{abort, printf};
use static_alloc::Bump;
@ -98,7 +98,7 @@ pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -17,7 +17,6 @@ use libafl::{
state::StdState,
};
use libafl_bolts::{
current_nanos,
ownedref::OwnedRefMut,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -64,7 +63,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -16,7 +16,7 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
use libc::c_uchar;
extern crate libc;
@ -51,7 +51,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -25,7 +25,6 @@ use libafl::{
Error,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
shmem::{unix_shmem, ShMem, ShMemId, ShMemProvider},
tuples::tuple_list,
@ -53,7 +52,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -21,7 +21,6 @@ use libafl_bolts::shmem::StdShMemProvider;
#[cfg(target_vendor = "apple")]
use libafl_bolts::shmem::UnixShMemProvider;
use libafl_bolts::{
current_nanos,
rands::StdRand,
shmem::{ShMem, ShMemProvider},
tuples::tuple_list,
@ -63,7 +62,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::<BytesInput>::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -19,7 +19,6 @@ use libafl::{
state::StdState,
};
use libafl_bolts::{
current_nanos,
ownedref::OwnedRefMut,
rands::StdRand,
shmem::{unix_shmem, ShMem, ShMemProvider},
@ -83,7 +82,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -18,7 +18,7 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
@ -75,7 +75,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -19,7 +19,6 @@ use libafl::{
HasMetadata,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{tuple_list, MatchNameRef, Merge, Referenceable},
@ -132,7 +131,7 @@ pub fn main() {
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::<BytesInput>::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -26,7 +26,6 @@ use libafl::{
use libafl::{feedback_and_fast, feedbacks::ConstFeedback};
use libafl_bolts::{
cli::{parse_args, FuzzerOptions},
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -153,7 +152,7 @@ unsafe fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),
@ -271,7 +270,7 @@ unsafe fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),
@ -404,7 +403,7 @@ unsafe fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),

View File

@ -36,7 +36,6 @@ use libafl::{
use libafl::{feedback_and_fast, feedbacks::ConstFeedback};
use libafl_bolts::{
cli::{parse_args, FuzzerOptions},
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -149,7 +148,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::new(PathBuf::from("./corpus_discovered"), 64).unwrap(),
// Corpus in which we store solutions (crashes in this example),
@ -266,7 +265,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),
@ -401,7 +400,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),

View File

@ -26,7 +26,6 @@ use libafl::{
use libafl::{feedback_and_fast, feedbacks::ConstFeedback};
use libafl_bolts::{
cli::{parse_args, FuzzerOptions},
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -143,7 +142,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),
@ -262,7 +261,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),
@ -395,7 +394,7 @@ unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
CachedOnDiskCorpus::no_meta(PathBuf::from("./corpus_discovered"), 64)
.unwrap(),

View File

@ -40,7 +40,7 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos, current_time,
current_time,
os::dup2,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -270,7 +270,7 @@ fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -43,7 +43,7 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos, current_time,
current_time,
os::dup2,
ownedref::OwnedMutSlice,
rands::StdRand,
@ -280,7 +280,7 @@ fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -38,7 +38,7 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos, current_time,
current_time,
os::{dup2, unix_signals::Signal},
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -268,7 +268,7 @@ fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -35,7 +35,7 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos, current_time,
current_time,
ownedref::OwnedRefMut,
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
@ -276,7 +276,7 @@ fn fuzz(
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::<BytesInput>::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -33,7 +33,7 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos, current_time,
current_time,
ownedref::OwnedRefMut,
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
@ -277,7 +277,7 @@ fn fuzz(
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::<BytesInput>::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -37,7 +37,7 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos, current_time,
current_time,
os::{dup2, unix_signals::Signal},
ownedref::OwnedMutSlice,
rands::StdRand,
@ -290,7 +290,7 @@ fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -46,7 +46,7 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos, current_time,
current_time,
os::dup2,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -337,7 +337,7 @@ fn fuzz_binary(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),
@ -549,7 +549,7 @@ fn fuzz_text(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -33,7 +33,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -161,7 +160,7 @@ pub extern "C" fn LLVMFuzzerRunDriver(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -26,7 +26,6 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
tuples::{tuple_list, Merge},
AsSlice,
@ -100,7 +99,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -27,7 +27,6 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
tuples::{tuple_list, Merge},
AsSlice,
@ -111,7 +110,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -27,7 +27,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -163,7 +162,7 @@ pub extern "C" fn libafl_main() {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -27,7 +27,6 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
tuples::{tuple_list, Merge},
AsSlice,
@ -125,7 +124,7 @@ fn fuzz(
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(corpus_dir).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -27,7 +27,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::{CoreId, Cores},
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -160,7 +159,7 @@ pub extern "C" fn libafl_main() {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -30,7 +30,6 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
tuples::{tuple_list, Merge},
AsSlice,
@ -110,7 +109,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -27,7 +27,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -161,7 +160,7 @@ pub extern "C" fn libafl_main() {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -31,7 +31,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::{tuple_list, Merge},
@ -186,7 +185,7 @@ pub extern "C" fn libafl_main() {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::new(&opt.input[0]).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -27,7 +27,6 @@ use libafl::{
Error, HasMetadata,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
tuples::{tuple_list, Merge},
AsSlice,
@ -109,7 +108,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -25,7 +25,7 @@ use libafl::{
state::{HasCorpus, StdState},
Error,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, std_edges_map_observer, CmpLogObserver,
};
@ -91,7 +91,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -20,7 +20,6 @@ use libafl::{
Error,
};
use libafl_bolts::{
current_nanos,
rands::StdRand,
tuples::{tuple_list, Merge},
AsSlice,
@ -87,7 +86,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -28,7 +28,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::tuple_list,
@ -159,7 +158,7 @@ pub extern "C" fn libafl_main() {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -15,7 +15,7 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::{CoreId, Cores},
rands::{RandomSeed, StdRand},
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::tuple_list,
};

View File

@ -13,10 +13,7 @@ use libafl::{
state::StdState,
Fuzzer, StdFuzzer,
};
use libafl_bolts::{
rands::{RandomSeed, StdRand},
tuples::tuple_list,
};
use libafl_bolts::{rands::StdRand, tuples::tuple_list};
use libafl_nyx::{executor::NyxExecutor, helper::NyxHelper, settings::NyxSettings};
fn main() {

View File

@ -20,7 +20,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
os::unix_signals::Signal,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -176,7 +175,7 @@ pub fn fuzz() -> Result<(), Error> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
StdRand::with_seed(current_nanos()),
StdRand::new(),
InMemoryOnDiskCorpus::new(PathBuf::from(options.output)).unwrap(),
NopCorpus::new(),
&mut feedback,

View File

@ -19,7 +19,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
os::unix_signals::Signal,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -216,7 +215,7 @@ pub fn fuzz() {
let mut state = state.unwrap_or_else(|| {
StdState::new(
StdRand::with_seed(current_nanos()),
StdRand::new(),
NopCorpus::new(),
NopCorpus::new(),
&mut feedback,

View File

@ -33,7 +33,6 @@ use libafl::{
use libafl_bolts::shmem::StdShMemProvider;
use libafl_bolts::{
core_affinity::CoreId,
current_nanos,
ownedref::OwnedMutSlice,
rands::StdRand,
tuples::{tuple_list, Merge},
@ -110,7 +109,7 @@ impl<'a, M: Monitor> Instance<'a, M> {
None => {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryOnDiskCorpus::no_meta(self.options.queue_dir(self.core_id))?,
// Corpus in which we store solutions (crashes in this example),

View File

@ -18,10 +18,7 @@ use libafl_bolts::shmem::UnixShMemProvider;
#[cfg(windows)]
use libafl_bolts::shmem::Win32ShMemProvider;
use libafl_bolts::{
ownedref::OwnedMutPtr,
rands::{RandomSeed, StdRand},
shmem::ShMemProvider,
tuples::tuple_list,
ownedref::OwnedMutPtr, rands::StdRand, shmem::ShMemProvider, tuples::tuple_list,
};
use libafl_tinyinst::executor::TinyInstExecutorBuilder;
static mut COVERAGE: Vec<u64> = vec![];

View File

@ -21,7 +21,7 @@ use libafl::{
state::{HasCorpus, StdState},
Error, Fuzzer,
};
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, std_edges_map_observer};
mod input;
@ -108,7 +108,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -1,12 +1,52 @@
//! The random number generators of `LibAFL`
use core::{debug_assert, fmt::Debug};
#[cfg(feature = "rand_trait")]
use rand_core::{impls::fill_bytes_via_next, RngCore};
use core::{
debug_assert,
fmt::Debug,
sync::atomic::{AtomicUsize, Ordering},
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
/// Return a pseudo-random seed. For `no_std` environments, a single deterministic sequence is used.
#[must_use]
#[allow(unreachable_code)]
pub fn random_seed() -> u64 {
#[cfg(feature = "std")]
return random_seed_from_random_state();
#[cfg(all(not(feature = "std"), target_has_atomic = "ptr"))]
return random_seed_deterministic();
// no_std and no atomics; https://xkcd.com/221/
4
}
static SEED_COUNTER: AtomicUsize = AtomicUsize::new(0);
#[allow(dead_code)]
#[cfg(target_has_atomic = "ptr")]
fn random_seed_deterministic() -> u64 {
let mut seed = SEED_COUNTER.fetch_add(1, Ordering::Relaxed) as u64;
splitmix64(&mut seed)
}
#[allow(dead_code)]
#[cfg(feature = "std")]
use crate::current_nanos;
fn random_seed_from_random_state() -> u64 {
use std::{
collections::hash_map::RandomState,
hash::{BuildHasher, Hasher},
};
RandomState::new().build_hasher().finish()
}
// https://prng.di.unimi.it/splitmix64.c
fn splitmix64(x: &mut u64) -> u64 {
*x = x.wrapping_add(0x9e3779b97f4a7c15);
let mut z = *x;
z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9);
z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb);
z ^ (z >> 31)
}
/// The standard rand implementation for `LibAFL`.
/// It is usually the right choice, with very good speed and a reasonable randomness.
@ -101,64 +141,36 @@ pub trait Rand: Debug + Serialize + DeserializeOwned {
}
}
// helper macro for deriving Default
macro_rules! default_rand {
macro_rules! impl_default_new {
($rand: ty) => {
/// A default RNG will usually produce a nondeterministic stream of random numbers.
/// As we do not have any way to get random seeds for `no_std`, they have to be reproducible there.
/// Use [`$rand::with_seed`] to generate a reproducible RNG.
impl Default for $rand {
#[cfg(feature = "std")]
/// Creates a generator seeded with [`random_seed`].
fn default() -> Self {
Self::new()
Self::with_seed(random_seed())
}
#[cfg(not(feature = "std"))]
fn default() -> Self {
Self::with_seed(0xAF1)
}
impl $rand {
/// Creates a generator seeded with [`random_seed`].
#[must_use]
pub fn new() -> Self {
Self::with_seed(random_seed())
}
}
};
}
// https://prng.di.unimi.it/splitmix64.c
fn splitmix64(x: &mut u64) -> u64 {
*x = x.wrapping_add(0x9e3779b97f4a7c15);
let mut z = *x;
z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9);
z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb);
z ^ (z >> 31)
}
impl_default_new!(Xoshiro256PlusPlusRand);
impl_default_new!(XorShift64Rand);
impl_default_new!(Lehmer64Rand);
impl_default_new!(RomuTrioRand);
impl_default_new!(RomuDuoJrRand);
impl_default_new!(Sfc64Rand);
// Derive Default by calling `new(DEFAULT_SEED)` on each of the following Rand types.
default_rand!(Xoshiro256PlusPlusRand);
default_rand!(XorShift64Rand);
default_rand!(Lehmer64Rand);
default_rand!(RomuTrioRand);
default_rand!(RomuDuoJrRand);
default_rand!(Sfc64Rand);
/// Initialize Rand types from a source of randomness.
///
/// Default implementations are provided with the "std" feature enabled, using system time in
/// nanoseconds as the initial seed.
pub trait RandomSeed: Rand + Default {
/// Creates a new [`RandomSeed`].
fn new() -> Self;
}
// helper macro to impl RandomSeed
macro_rules! impl_random {
macro_rules! impl_rng_core {
($rand: ty) => {
#[cfg(feature = "std")]
impl RandomSeed for $rand {
/// Creates a rand instance, pre-seeded with the current time in nanoseconds.
fn new() -> Self {
Self::with_seed(current_nanos())
}
}
#[cfg(feature = "rand_trait")]
impl RngCore for $rand {
impl rand_core::RngCore for $rand {
fn next_u32(&mut self) -> u32 {
self.next() as u32
}
@ -168,7 +180,7 @@ macro_rules! impl_random {
}
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest)
rand_core::impls::fill_bytes_via_next(self, dest)
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
@ -178,12 +190,12 @@ macro_rules! impl_random {
};
}
impl_random!(Xoshiro256PlusPlusRand);
impl_random!(XorShift64Rand);
impl_random!(Lehmer64Rand);
impl_random!(RomuTrioRand);
impl_random!(RomuDuoJrRand);
impl_random!(Sfc64Rand);
impl_rng_core!(Xoshiro256PlusPlusRand);
impl_rng_core!(XorShift64Rand);
impl_rng_core!(Lehmer64Rand);
impl_rng_core!(RomuTrioRand);
impl_rng_core!(RomuDuoJrRand);
impl_rng_core!(Sfc64Rand);
/// xoshiro256++ PRNG: <https://prng.di.unimi.it/>
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
@ -480,38 +492,75 @@ mod tests {
test_single_rand(&mut Sfc64Rand::with_seed(0));
}
#[cfg(feature = "std")]
#[test]
fn test_random_seed() {
use crate::rands::RandomSeed;
fn test_romutrio_golden() {
// https://github.com/ziglang/zig/blob/130fb5cb0fb9039e79450c9db58d6590c5bee3b3/lib/std/Random/RomuTrio.zig#L75-L95
let golden: [u64; 10] = [
16294208416658607535,
13964609475759908645,
4703697494102998476,
3425221541186733346,
2285772463536419399,
9454187757529463048,
13695907680080547496,
8328236714879408626,
12323357569716880909,
12375466223337721820,
];
let mut rand_fixed = StdRand::with_seed(0);
let mut rand = StdRand::new();
// The seed should be reasonably random so these never fail
assert_ne!(rand.next(), rand_fixed.next());
test_single_rand(&mut rand);
let mut s = RomuTrioRand::with_seed(0);
for v in golden {
let u = s.next();
assert_eq!(v, u);
}
}
#[test]
#[cfg(feature = "rand_trait")]
fn test_rgn_core_support() {
use rand_core::RngCore;
fn test_romuduojr_golden() {
// https://github.com/eqv/rand_romu/blob/c0379dc3c21ffac8440197e2f8fe95c226c44bfe/src/lib.rs#L65-L79
let golden: [u64; 9] = [
0x3c91b13ee3913664,
0xdc1980b78df3115,
0x1c163b704996d2ad,
0xa000c594bb28313b,
0xfb6c42e69a523526,
0x1fcebd6988ab21d8,
0x5e0a8abf025f8f02,
0x29554b00ffab0263,
0xff5b6bb1551cf66,
];
use crate::rands::StdRand;
pub struct Mutator<R: RngCore> {
rng: R,
}
let mut mutator = Mutator {
rng: StdRand::with_seed(0),
let mut s = RomuDuoJrRand {
x_state: 0x3c91b13ee3913664u64,
y_state: 0x863f0e37c2637d1fu64,
};
log::info!("random value: {}", mutator.rng.next_u32());
for v in golden {
let u = s.next();
assert_eq!(v, u);
}
}
#[test]
fn test_sfc64_golden_zig() {
fn test_xoshiro256pp_golden() {
// https://github.com/ziglang/zig/blob/130fb5cb0fb9039e79450c9db58d6590c5bee3b3/lib/std/Random/Xoshiro256.zig#L96-L103
let golden: [u64; 6] = [
0x53175d61490b23df,
0x61da6f3dc380d507,
0x5c0fdf91ec9a7bfc,
0x02eebf8c3bbe5e1a,
0x7eca04ebaf4a5eea,
0x0543c37757f08d9a,
];
let mut s = Xoshiro256PlusPlusRand::with_seed(0);
for v in golden {
let u = s.next();
assert_eq!(v, u);
}
}
#[test]
fn test_sfc64_golden() {
// https://github.com/ziglang/zig/blob/130fb5cb0fb9039e79450c9db58d6590c5bee3b3/lib/std/Random/Sfc64.zig#L73-L99
let golden: [u64; 16] = [
0x3acfa029e3cc6041,
@ -548,8 +597,7 @@ pub mod pybind {
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use super::Rand;
use crate::{current_nanos, rands::StdRand};
use super::{random_seed, Rand, StdRand};
#[pyclass(unsendable, name = "StdRand")]
#[allow(clippy::unsafe_derive_deserialize)]
@ -563,9 +611,9 @@ pub mod pybind {
#[pymethods]
impl PythonStdRand {
#[staticmethod]
fn with_current_nanos() -> Self {
fn with_random_seed() -> Self {
Self {
inner: StdRand::with_seed(current_nanos()),
inner: StdRand::with_seed(random_seed()),
}
}

View File

@ -593,7 +593,7 @@ pub mod unix_shmem {
};
use crate::{
rands::{Rand, RandomSeed, StdRand},
rands::{Rand, StdRand},
shmem::{ShMem, ShMemId, ShMemProvider},
Error,
};

View File

@ -150,7 +150,6 @@ impl CustomMutationStatus {
macro_rules! fuzz_with {
($options:ident, $harness:ident, $operation:expr, $and_then:expr, $edge_maker:expr) => {{
use libafl_bolts::{
current_nanos,
rands::StdRand,
tuples::{Merge, tuple_list},
AsSlice,
@ -282,7 +281,7 @@ macro_rules! fuzz_with {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
LibfuzzerCorpus::new(corpus_dir.clone(), 4096),
// Corpus in which we store solutions (crashes in this example),

View File

@ -22,7 +22,7 @@ use libafl::{
Error, HasScheduler, StdFuzzer,
};
use libafl_bolts::{
rands::{Rand, RandomSeed, StdRand},
rands::{Rand, StdRand},
shmem::{ShMemProvider, StdShMemProvider},
tuples::tuple_list,
AsSlice,

View File

@ -16,7 +16,7 @@ use libafl::{
Error, Fuzzer, StdFuzzer,
};
use libafl_bolts::{
rands::{RandomSeed, RomuDuoJrRand, StdRand},
rands::{RomuDuoJrRand, StdRand},
shmem::{ShMemProvider, StdShMemProvider},
tuples::tuple_list,
AsSlice, HasLen,

View File

@ -23,7 +23,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
rands::StdRand,
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
tuples::{tuple_list, Merge, Referenceable},
@ -153,7 +152,7 @@ impl<'a> ForkserverBytesCoverageSugar<'a> {
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep a part in memory for performance
CachedOnDiskCorpus::new(out_dir.clone(), CORPUS_CACHE_SIZE).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -26,7 +26,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
ownedref::OwnedMutSlice,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -178,7 +177,7 @@ where
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep a part in memory for performance
CachedOnDiskCorpus::new(out_dir.clone(), CORPUS_CACHE_SIZE).unwrap(),
// Corpus in which we store solutions (crashes in this example),

View File

@ -29,7 +29,6 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::Cores,
current_nanos,
ownedref::OwnedMutSlice,
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
@ -188,7 +187,7 @@ where
let mut state = state.unwrap_or_else(|| {
StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
StdRand::new(),
// Corpus that will be evolved, we keep a part in memory for performance
CachedOnDiskCorpus::new(out_dir.clone(), CORPUS_CACHE_SIZE).unwrap(),
// Corpus in which we store solutions (crashes in this example),