From 8fb80c3f3a00815dee72fbe82dd13c5caaf9ab0f Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Tue, 30 Jul 2024 14:48:17 +0200 Subject: [PATCH] libafl_qemu: Continue build with outdated LLVM, ignore TUI race conditions (#2461) * libafl_qemu: Continue build with outdated LLVM * Ignore race condition * ignore more race conditions, remove useless clones * fix fixes --- fuzzers/qemu/qemu_launcher/Cargo.toml | 1 + .../qemu_launcher/injection_test/.gitignore | 2 + libafl/src/monitors/tui/ui.rs | 66 ++++++++++--------- libafl_qemu/libafl_qemu_build/src/lib.rs | 7 +- 4 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 fuzzers/qemu/qemu_launcher/injection_test/.gitignore diff --git a/fuzzers/qemu/qemu_launcher/Cargo.toml b/fuzzers/qemu/qemu_launcher/Cargo.toml index f6b5490dfb..f5f34bbbdf 100644 --- a/fuzzers/qemu/qemu_launcher/Cargo.toml +++ b/fuzzers/qemu/qemu_launcher/Cargo.toml @@ -10,6 +10,7 @@ edition = "2021" [features] default = ["std", "injections"] std = [] +clippy = [] # Only for clippy, don't use. ## Build with a simple event manager instead of Launcher - don't fork, and crash after the first bug. simplemgr = [] diff --git a/fuzzers/qemu/qemu_launcher/injection_test/.gitignore b/fuzzers/qemu/qemu_launcher/injection_test/.gitignore new file mode 100644 index 0000000000..2d8ba7c535 --- /dev/null +++ b/fuzzers/qemu/qemu_launcher/injection_test/.gitignore @@ -0,0 +1,2 @@ +sqltest +static \ No newline at end of file diff --git a/libafl/src/monitors/tui/ui.rs b/libafl/src/monitors/tui/ui.rs index 403f9bc56f..a74014b8ad 100644 --- a/libafl/src/monitors/tui/ui.rs +++ b/libafl/src/monitors/tui/ui.rs @@ -148,8 +148,7 @@ impl TuiUi { .constraints([Constraint::Length(3), Constraint::Min(0)].as_ref()) .split(left_top_layout[0]); - let mut status_bar: String = self.title.clone(); - status_bar = status_bar + " (" + self.version.as_str() + ")"; + let status_bar: String = format!("{} ({})", self.title, self.version.as_str()); let text = vec![Line::from(Span::styled( &status_bar, @@ -425,18 +424,22 @@ impl TuiUi { area: Rect, is_overall: bool, ) { - let item_geometry: ItemGeometry = if is_overall { - app.read().unwrap().total_item_geometry.clone() + let tui_context = app.read().unwrap(); + let empty_geometry: ItemGeometry = ItemGeometry::new(); + let item_geometry: &ItemGeometry = if is_overall { + &tui_context.total_item_geometry } else if self.clients < 2 { - ItemGeometry::new() + &empty_geometry } else { - app.read() - .unwrap() - .clients - .get(&self.clients_idx) - .unwrap() - .item_geometry - .clone() + let clients = &tui_context.clients; + let client = clients.get(&self.clients_idx); + let client = client.as_ref(); + if let Some(client) = client { + &client.item_geometry + } else { + log::warn!("Client {} was `None`. Race condition?", &self.clients_idx); + &empty_geometry + } }; let items = vec![ @@ -458,7 +461,7 @@ impl TuiUi { ]), Row::new(vec![ Cell::from(Span::raw("stability")), - Cell::from(Span::raw(item_geometry.stability)), + Cell::from(Span::raw(&item_geometry.stability)), ]), ]; @@ -495,26 +498,25 @@ impl TuiUi { area: Rect, is_overall: bool, ) { - let tup: (Duration, ProcessTiming) = if is_overall { - let tui_context = app.read().unwrap(); - ( - tui_context.start_time, - tui_context.total_process_timing.clone(), - ) + let tui_context = app.read().unwrap(); + let empty_timing: ProcessTiming = ProcessTiming::new(); + let tup: (Duration, &ProcessTiming) = if is_overall { + (tui_context.start_time, &tui_context.total_process_timing) } else if self.clients < 2 { - (current_time(), ProcessTiming::new()) + (current_time(), &empty_timing) } else { - let client = app - .read() - .unwrap() - .clients - .get(&self.clients_idx) - .unwrap() - .clone(); - ( - client.process_timing.client_start_time, - client.process_timing, - ) + let clients = &tui_context.clients; + let client = clients.get(&self.clients_idx); + let client = client.as_ref(); + if let Some(client) = client { + ( + client.process_timing.client_start_time, + &client.process_timing, + ) + } else { + log::warn!("Client {} was `None`. Race condition?", &self.clients_idx); + (current_time(), &empty_timing) + } }; let items = vec![ Row::new(vec![ @@ -523,7 +525,7 @@ impl TuiUi { ]), Row::new(vec![ Cell::from(Span::raw("exec speed")), - Cell::from(Span::raw(tup.1.exec_speed)), + Cell::from(Span::raw(&tup.1.exec_speed)), ]), Row::new(vec![ Cell::from(Span::raw("last new entry")), diff --git a/libafl_qemu/libafl_qemu_build/src/lib.rs b/libafl_qemu/libafl_qemu_build/src/lib.rs index b346bad0b4..b98f499f08 100644 --- a/libafl_qemu/libafl_qemu_build/src/lib.rs +++ b/libafl_qemu/libafl_qemu_build/src/lib.rs @@ -108,11 +108,10 @@ fn find_llvm_config() -> Result { if which("llvm-config").is_ok() { if let Some(ver) = find_llvm_version("llvm-config".to_owned()) { - if ver >= rustc_llvm_ver { - return Ok("llvm-config".to_owned()); + if ver < rustc_llvm_ver { + println!("cargo:warning=Version of llvm-config is {ver} but needs to be at least rustc's version ({rustc_llvm_ver})! We will (try to) continue to build. Continue at your own risk, or rebuild with a set LLVM_CONFIG_PATH env variable, pointing to a newer version."); } - - return Err(format!("Version of llvm-config is {ver} but needs to be at least rustc's version({rustc_llvm_ver})")); + return Ok("llvm-config".to_owned()); } }