Skip to content

Commit

Permalink
libafl_qemu: Continue build with outdated LLVM, ignore TUI race condi…
Browse files Browse the repository at this point in the history
…tions (AFLplusplus#2461)

* libafl_qemu: Continue build with outdated LLVM

* Ignore race condition

* ignore more race conditions, remove useless clones

* fix fixes
  • Loading branch information
domenukk authored Jul 30, 2024
1 parent c319fe2 commit 8fb80c3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 36 deletions.
1 change: 1 addition & 0 deletions fuzzers/qemu/qemu_launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 2 additions & 0 deletions fuzzers/qemu/qemu_launcher/injection_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sqltest
static
66 changes: 34 additions & 32 deletions libafl/src/monitors/tui/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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![
Expand All @@ -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)),
]),
];

Expand Down Expand Up @@ -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![
Expand All @@ -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")),
Expand Down
7 changes: 3 additions & 4 deletions libafl_qemu/libafl_qemu_build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ fn find_llvm_config() -> Result<String, String> {

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());
}
}

Expand Down

0 comments on commit 8fb80c3

Please sign in to comment.