Add core_id to launcher run_client
closure signature (#290)
* Add core_id to launcher run_client closure signature * Format * Attempt to fix windows build * windows * Sleep for index seconds instead of id seconds when launching cores (#292)
This commit is contained in:
parent
b71704b14d
commit
b4aa22458d
@ -294,7 +294,7 @@ unsafe fn fuzz(
|
||||
|
||||
let shmem_provider = StdShMemProvider::new()?;
|
||||
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr| {
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
|
||||
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
|
||||
|
||||
let lib = libloading::Library::new(module_name).unwrap();
|
||||
|
@ -83,7 +83,7 @@ pub fn libafl_main() {
|
||||
|
||||
let stats = MultiStats::new(|s| println!("{}", s));
|
||||
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr| {
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
|
||||
// Create an observation channel using the coverage map
|
||||
let edges = unsafe { &mut EDGES_MAP[0..MAX_EDGES_NUM] };
|
||||
let edges_observer = HitcountsMapObserver::new(StdMapObserver::new("edges", edges));
|
||||
|
@ -60,7 +60,7 @@ pub fn libafl_main() {
|
||||
|
||||
let stats = MultiStats::new(|s| println!("{}", s));
|
||||
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut restarting_mgr| {
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut restarting_mgr, _core_id| {
|
||||
let corpus_dirs = &[PathBuf::from("./corpus")];
|
||||
let objective_dir = PathBuf::from("./crashes");
|
||||
|
||||
|
@ -33,8 +33,11 @@ use typed_builder::TypedBuilder;
|
||||
|
||||
/// The Launcher client callback type reference
|
||||
#[cfg(feature = "std")]
|
||||
pub type LauncherClientFnRef<'a, I, OT, S, SP> =
|
||||
&'a mut dyn FnMut(Option<S>, LlmpRestartingEventManager<I, OT, S, SP>) -> Result<(), Error>;
|
||||
pub type LauncherClientFnRef<'a, I, OT, S, SP> = &'a mut dyn FnMut(
|
||||
Option<S>,
|
||||
LlmpRestartingEventManager<I, OT, S, SP>,
|
||||
usize,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
const _AFL_LAUNCHER_CLIENT: &str = "AFL_LAUNCHER_CLIENT";
|
||||
/// Provides a Launcher, which can be used to launch a fuzzing run on a specified list of cores
|
||||
@ -100,7 +103,7 @@ where
|
||||
.map(|filename| File::create(filename).unwrap());
|
||||
|
||||
// Spawn clients
|
||||
for (id, bind_to) in core_ids.iter().enumerate().take(num_cores) {
|
||||
for (index, (id, bind_to)) in core_ids.iter().enumerate().take(num_cores).enumerate() {
|
||||
if self.cores.iter().any(|&x| x == id) {
|
||||
self.shmem_provider.pre_fork()?;
|
||||
match unsafe { fork() }? {
|
||||
@ -115,7 +118,7 @@ where
|
||||
self.shmem_provider.post_fork(true)?;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
std::thread::sleep(std::time::Duration::from_secs((id + 1) as u64));
|
||||
std::thread::sleep(std::time::Duration::from_secs((index + 1) as u64));
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
if file.is_some() {
|
||||
@ -133,7 +136,7 @@ where
|
||||
.build()
|
||||
.launch()?;
|
||||
|
||||
(self.run_client)(state, mgr)?;
|
||||
(self.run_client)(state, mgr, bind_to.id)?;
|
||||
break;
|
||||
}
|
||||
};
|
||||
@ -200,7 +203,7 @@ where
|
||||
.build()
|
||||
.launch()?;
|
||||
|
||||
(self.run_client)(state, mgr)?;
|
||||
(self.run_client)(state, mgr, core_conf.parse()?)?;
|
||||
|
||||
unreachable!("Fuzzer client code should never get here!");
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ where
|
||||
|
||||
let stats = MultiStats::new(|s| println!("{}", s));
|
||||
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr| {
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
|
||||
// Create an observation channel using the coverage map
|
||||
let edges = unsafe { &mut EDGES_MAP[0..MAX_EDGES_NUM] };
|
||||
let edges_observer = HitcountsMapObserver::new(StdMapObserver::new("edges", edges));
|
||||
|
@ -113,7 +113,7 @@ where
|
||||
|
||||
let stats = MultiStats::new(|s| println!("{}", s));
|
||||
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr| {
|
||||
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
|
||||
// Create an observation channel using the coverage map
|
||||
let edges = unsafe { &mut hooks::EDGES_MAP };
|
||||
let edges_counter = unsafe { &mut hooks::MAX_EDGES_NUM };
|
||||
|
Loading…
x
Reference in New Issue
Block a user