Skip to content

Commit

Permalink
Fix WeightedScheduler reporting incorrect queue cylces (AFLplusplus#2281
Browse files Browse the repository at this point in the history
)

* fix WeightedScheduler reporting incorrect queue cylces

* check if runs_in_cycle equals or greater instead of just equals

---------

Co-authored-by: Dongjia "toka" Zhang <[email protected]>
  • Loading branch information
R9295 and tokatoka authored Jun 6, 2024
1 parent af12b4b commit a455ad2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libafl/src/schedulers/weighted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ where

let wsmeta = state.metadata_mut::<WeightedScheduleMetadata>()?;

let current_cycles = wsmeta.runs_in_current_cycle();
let runs_in_current_cycle = wsmeta.runs_in_current_cycle();

// TODO deal with corpus_counts decreasing due to removals
if current_cycles >= corpus_counts {
if runs_in_current_cycle >= corpus_counts {
wsmeta.set_runs_current_cycle(0);
} else {
wsmeta.set_runs_current_cycle(current_cycles + 1);
wsmeta.set_runs_current_cycle(runs_in_current_cycle + 1);
}

let idx = if probability < *wsmeta.alias_probability().get(&s).unwrap() {
Expand All @@ -340,7 +340,7 @@ where
};

// Update depth
if current_cycles > corpus_counts {
if runs_in_current_cycle >= corpus_counts {
let psmeta = state.metadata_mut::<SchedulerMetadata>()?;
psmeta.set_queue_cycles(psmeta.queue_cycles() + 1);
}
Expand Down

0 comments on commit a455ad2

Please sign in to comment.