Change when to setup the ctrl c handler. (#2198)

* copy

* fmt

* aa

* a

* Goodbye z3, i hope i won't build you forever

* doc

* fmt

* fix

* aa
This commit is contained in:
Dongjia "toka" Zhang 2024-05-16 14:27:14 +02:00 committed by GitHub
parent 41d41f25bf
commit e31658b914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 30 deletions

View File

@ -1556,6 +1556,7 @@ where
handle.status() handle.status()
} }
ForkResult::Child => { ForkResult::Child => {
println!("AAA!");
self.shmem_provider.post_fork(true)?; self.shmem_provider.post_fork(true)?;
break (staterestorer, self.shmem_provider.clone(), core_id); break (staterestorer, self.shmem_provider.clone(), core_id);
} }
@ -1607,16 +1608,6 @@ where
ctr = ctr.wrapping_add(1); ctr = ctr.wrapping_add(1);
} }
} else { } else {
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) =
unsafe { setup_signal_handler(addr_of_mut!(EVENTMGR_SIGHANDLER_STATE)) }
{
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
// We are the newly started fuzzing instance (i.e. on Windows), first, connect to our own restore map. // We are the newly started fuzzing instance (i.e. on Windows), first, connect to our own restore map.
// We get here *only on Windows*, if we were started by a restarting fuzzer. // We get here *only on Windows*, if we were started by a restarting fuzzer.
// A staterestorer and a receiver for single communication // A staterestorer and a receiver for single communication
@ -1627,6 +1618,14 @@ where
) )
}; };
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) = unsafe { setup_signal_handler(addr_of_mut!(EVENTMGR_SIGHANDLER_STATE)) } {
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
if let Some(core_id) = core_id { if let Some(core_id) = core_id {
let core_id: CoreId = core_id; let core_id: CoreId = core_id;
core_id.set_affinity()?; core_id.set_affinity()?;

View File

@ -537,22 +537,20 @@ where
ctr = ctr.wrapping_add(1); ctr = ctr.wrapping_add(1);
} }
} else { } else {
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) =
unsafe { setup_signal_handler(addr_of_mut!(EVENTMGR_SIGHANDLER_STATE)) }
{
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
// We are the newly started fuzzing instance (i.e. on Windows), first, connect to our own restore map. // We are the newly started fuzzing instance (i.e. on Windows), first, connect to our own restore map.
// We get here *only on Windows*, if we were started by a restarting fuzzer. // We get here *only on Windows*, if we were started by a restarting fuzzer.
// A staterestorer and a receiver for single communication // A staterestorer and a receiver for single communication
StateRestorer::from_env(shmem_provider, _ENV_FUZZER_SENDER)? StateRestorer::from_env(shmem_provider, _ENV_FUZZER_SENDER)?
}; };
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) = unsafe { setup_signal_handler(addr_of_mut!(EVENTMGR_SIGHANDLER_STATE)) } {
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
// If we're restarting, deserialize the old state. // If we're restarting, deserialize the old state.
let (state, mgr) = match staterestorer.restore::<(S, Duration, Vec<ClientStats>)>()? { let (state, mgr) = match staterestorer.restore::<(S, Duration, Vec<ClientStats>)>()? {
None => { None => {

View File

@ -1295,16 +1295,6 @@ where
ctr = ctr.wrapping_add(1); ctr = ctr.wrapping_add(1);
} }
} else { } else {
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) =
unsafe { setup_signal_handler(addr_of_mut!(EVENTMGR_SIGHANDLER_STATE)) }
{
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
// We are the newly started fuzzing instance (i.e. on Windows), first, connect to our own restore map. // We are the newly started fuzzing instance (i.e. on Windows), first, connect to our own restore map.
// We get here *only on Windows*, if we were started by a restarting fuzzer. // We get here *only on Windows*, if we were started by a restarting fuzzer.
// A staterestorer and a receiver for single communication // A staterestorer and a receiver for single communication
@ -1315,6 +1305,14 @@ where
) )
}; };
// At this point we are the fuzzer *NOT* the restarter.
// We setup signal handlers to clean up shmem segments used by state restorer
#[cfg(all(unix, not(miri)))]
if let Err(_e) = unsafe { setup_signal_handler(addr_of_mut!(EVENTMGR_SIGHANDLER_STATE)) } {
// We can live without a proper ctrl+c signal handler. Print and ignore.
log::error!("Failed to setup signal handlers: {_e}");
}
if let Some(core_id) = core_id { if let Some(core_id) = core_id {
let core_id: CoreId = core_id; let core_id: CoreId = core_id;
core_id.set_affinity()?; core_id.set_affinity()?;