Skip to content

Commit

Permalink
Batch timeout fix (AFLplusplus#2109)
Browse files Browse the repository at this point in the history
* fix

* FMT

* unused
  • Loading branch information
tokatoka authored Apr 26, 2024
1 parent 32963be commit 084b9b5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fuzzers/fuzzbench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, std_edges_map_observer, CmpLogObserver,
};
#[cfg(unix)]
use nix::{self, unistd::dup};
use nix::unistd::dup;

/// The fuzzer main (as `no_mangle` C function)
#[no_mangle]
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/fuzzbench_fork_qemu/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use libafl_qemu::{
QemuShutdownCause, Regs,
};
#[cfg(unix)]
use nix::{self, unistd::dup};
use nix::unistd::dup;

/// The fuzzer main
pub fn main() {
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/fuzzbench_qemu/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use libafl_qemu::{
Regs,
};
#[cfg(unix)]
use nix::{self, unistd::dup};
use nix::unistd::dup;

pub const MAX_INPUT_SIZE: usize = 1048576; // 1MB

Expand Down
2 changes: 1 addition & 1 deletion fuzzers/fuzzbench_text/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, std_edges_map_observer, CmpLogObserver,
};
#[cfg(unix)]
use nix::{self, unistd::dup};
use nix::unistd::dup;

/// The fuzzer main (as `no_mangle` C function)
#[no_mangle]
Expand Down
4 changes: 2 additions & 2 deletions libafl/src/executors/hooks/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ impl TimerStruct {
if self.batch_mode {
unsafe {
let elapsed = current_time().saturating_sub(self.tmout_start_time);
let elapsed_since_signal = current_time().saturating_sub(self.tmout_start_time);
// elapsed may be > than tmout in case of received but ingored signal
if elapsed > self.exec_tmout
|| self.exec_tmout.saturating_sub(elapsed) < self.avg_exec_time * self.avg_mul_k
Expand All @@ -337,8 +338,7 @@ impl TimerStruct {
self.executions = 0;
}
// readjust K
if self.last_signal_time > self.exec_tmout * self.avg_mul_k
&& self.avg_mul_k > 1
if elapsed_since_signal > self.exec_tmout * self.avg_mul_k && self.avg_mul_k > 1
{
self.avg_mul_k -= 1;
}
Expand Down

0 comments on commit 084b9b5

Please sign in to comment.