Always show user monitor in SimpleMonitor (#3202)
* *recursion* is not proper * user monitor on * api changer * no submodule anymore
This commit is contained in:
parent
f33376f1cd
commit
d8f8640982
@ -203,7 +203,7 @@ pub fn main() {
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
#[cfg(not(feature = "tui"))]
|
||||
let mon = SimpleMonitor::with_user_monitor(|s| println!("{s}"));
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
#[cfg(feature = "tui")]
|
||||
let mon = TuiMonitor::builder()
|
||||
.title("Baby Fuzzer")
|
||||
|
@ -232,7 +232,7 @@ fn fuzz(
|
||||
let file_null = File::open("/dev/null")?;
|
||||
|
||||
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
|
||||
let monitor = SimpleMonitor::with_user_monitor(|s| {
|
||||
let monitor = SimpleMonitor::new(|s| {
|
||||
#[cfg(unix)]
|
||||
writeln!(&mut stdout_cpy, "{s}").unwrap();
|
||||
#[cfg(windows)]
|
||||
|
@ -180,7 +180,7 @@ pub fn fuzz() -> Result<(), Error> {
|
||||
|
||||
let stack_ptr: GuestAddr = qemu.read_reg(Regs::Sp).unwrap();
|
||||
|
||||
let monitor = SimpleMonitor::with_user_monitor(|s| {
|
||||
let monitor = SimpleMonitor::new(|s| {
|
||||
println!("{s}");
|
||||
});
|
||||
let (state, mut mgr) = match SimpleRestartingEventManager::launch(monitor, &mut shmem_provider)
|
||||
|
@ -223,7 +223,7 @@ pub fn fuzz() -> Result<(), Error> {
|
||||
};
|
||||
|
||||
// Set up the most basic monitor possible.
|
||||
let monitor = SimpleMonitor::with_user_monitor(|s| {
|
||||
let monitor = SimpleMonitor::new(|s| {
|
||||
println!("{s}");
|
||||
});
|
||||
let (state, mut mgr) = match SimpleRestartingEventManager::launch(monitor, &mut shmem_provider)
|
||||
|
@ -149,7 +149,7 @@ pub fn main() {
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are reported to the user
|
||||
let monitor = SimpleMonitor::with_user_monitor(|s| {
|
||||
let monitor = SimpleMonitor::new(|s| {
|
||||
println!("{s}");
|
||||
});
|
||||
|
||||
|
@ -153,7 +153,6 @@ where
|
||||
F: FnMut(&str),
|
||||
{
|
||||
print_fn: F,
|
||||
print_user_monitor: bool,
|
||||
}
|
||||
|
||||
impl<F> Debug for SimpleMonitor<F>
|
||||
@ -188,13 +187,11 @@ where
|
||||
global_stats.execs_per_sec_pretty
|
||||
);
|
||||
|
||||
if self.print_user_monitor {
|
||||
client_stats_manager.client_stats_insert(sender_id)?;
|
||||
let client = client_stats_manager.client_stats_for(sender_id)?;
|
||||
for (key, val) in client.user_stats() {
|
||||
write!(fmt, ", {key}: {val}").unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
(self.print_fn)(&fmt);
|
||||
|
||||
@ -222,10 +219,7 @@ where
|
||||
{
|
||||
/// Creates the monitor, using the `current_time` as `start_time`.
|
||||
pub fn new(print_fn: F) -> Self {
|
||||
Self {
|
||||
print_fn,
|
||||
print_user_monitor: false,
|
||||
}
|
||||
Self { print_fn }
|
||||
}
|
||||
|
||||
/// Creates the monitor with a given `start_time`.
|
||||
@ -236,14 +230,6 @@ where
|
||||
pub fn with_time(print_fn: F, _start_time: Duration) -> Self {
|
||||
Self::new(print_fn)
|
||||
}
|
||||
|
||||
/// Creates the monitor that also prints the user monitor
|
||||
pub fn with_user_monitor(print_fn: F) -> Self {
|
||||
Self {
|
||||
print_fn,
|
||||
print_user_monitor: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start the timer
|
||||
|
@ -1,12 +1,11 @@
|
||||
//! Forkserver logic into targets
|
||||
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::{
|
||||
os::fd::{AsFd, AsRawFd, BorrowedFd},
|
||||
sync::OnceLock,
|
||||
};
|
||||
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use libafl::{
|
||||
Error,
|
||||
executors::forkserver::{
|
||||
@ -15,7 +14,6 @@ use libafl::{
|
||||
},
|
||||
};
|
||||
use libafl_bolts::os::{ChildHandle, ForkResult};
|
||||
|
||||
use nix::{
|
||||
sys::signal::{SigHandler, Signal},
|
||||
unistd::Pid,
|
||||
@ -293,10 +291,7 @@ impl ForkserverParent for MaybePersistentForkserverParent {
|
||||
// a child, wait it, and get a stopped signal. Moreover, was_killed is
|
||||
// true only if the forkserver killed such child. In all cases, the
|
||||
// last_child_pid will never be None.
|
||||
if nix::sys::wait::waitpid(
|
||||
Pid::from_raw(self.last_child_pid.take().unwrap()),
|
||||
None,
|
||||
)
|
||||
if nix::sys::wait::waitpid(Pid::from_raw(self.last_child_pid.take().unwrap()), None)
|
||||
.is_err()
|
||||
{
|
||||
return Err(Error::illegal_state("child_stopped && was_killed"));
|
||||
@ -323,12 +318,18 @@ impl ForkserverParent for MaybePersistentForkserverParent {
|
||||
}
|
||||
ForkResult::Child => unsafe {
|
||||
// unwrap here: the field is assigned in `pre_fuzzing`
|
||||
nix::sys::signal::signal(Signal::SIGCHLD, self.old_sigchld_handler.take().unwrap())
|
||||
nix::sys::signal::signal(
|
||||
Signal::SIGCHLD,
|
||||
self.old_sigchld_handler.take().unwrap(),
|
||||
)
|
||||
.inspect_err(|_| {
|
||||
log::error!("Fail to restore signal handler for SIGCHLD.");
|
||||
})?;
|
||||
// unwrap here: the field is assigned in `pre_fuzzing`
|
||||
nix::sys::signal::signal(Signal::SIGTERM, self.old_sigterm_handler.take().unwrap())
|
||||
nix::sys::signal::signal(
|
||||
Signal::SIGTERM,
|
||||
self.old_sigterm_handler.take().unwrap(),
|
||||
)
|
||||
.inspect_err(|_| {
|
||||
log::error!("Fail to restore signal handler for SIGTERM.");
|
||||
})?;
|
||||
@ -341,7 +342,8 @@ impl ForkserverParent for MaybePersistentForkserverParent {
|
||||
fn handle_child_requests(&mut self) -> Result<i32, Error> {
|
||||
let mut status = 0i32;
|
||||
// unwrap here: the field is assigned if we are parent process in `spawn_child`
|
||||
if unsafe { libc::waitpid(*self.last_child_pid.as_ref().unwrap(), &raw mut status, 0) < 0 } {
|
||||
if unsafe { libc::waitpid(*self.last_child_pid.as_ref().unwrap(), &raw mut status, 0) < 0 }
|
||||
{
|
||||
return Err(Error::illegal_state("waitpid"));
|
||||
}
|
||||
if libc::WIFSTOPPED(status) {
|
||||
|
@ -5,22 +5,11 @@ cd "$SCRIPT_DIR/.." || exit 1
|
||||
# TODO: This should be rewritten in rust, a Makefile, or some platform-independent language
|
||||
|
||||
|
||||
if [[ -z "${RUN_ON_CI}" ]]; then
|
||||
fuzzers=$(find ./fuzzers -mindepth 1 -maxdepth 1 -type d)
|
||||
backtrace_fuzzers=$(find ./fuzzers/backtrace_baby_fuzzers -mindepth 1 -maxdepth 1 -type d)
|
||||
fuzzer_to_test="$fuzzers $backtrace_fuzzers"
|
||||
else
|
||||
fuzzer_to_test="$1"
|
||||
export PROFILE=dev
|
||||
export PROFILE_DIR=debug
|
||||
fi
|
||||
|
||||
echo "Testing" "$fuzzer_to_test"
|
||||
# build with a shared target dir for all fuzzers. this should speed up
|
||||
# compilation a bit, and allows for easier artifact management (caching and
|
||||
# cargo clean).
|
||||
|
||||
git submodule init && git submodule update
|
||||
|
||||
# override default profile settings for speed
|
||||
# export RUSTFLAGS="-C prefer-dynamic"
|
||||
|
Loading…
x
Reference in New Issue
Block a user