diff --git a/fuzzers/FRET/src/systemstate/stg.rs b/fuzzers/FRET/src/systemstate/stg.rs index 98f3840160..4c893b46a8 100644 --- a/fuzzers/FRET/src/systemstate/stg.rs +++ b/fuzzers/FRET/src/systemstate/stg.rs @@ -268,7 +268,8 @@ pub type GraphMaximizerCorpusScheduler = MinimizerScheduler::State>,STGNodeMetadata,O>; // AI generated, human verified -fn count_occurrences(vec: &Vec) -> HashMap<&T, usize> +/// Count the occurrences of each element in a vector, assumes the vector is sorted +fn count_occurrences_sorted(vec: &Vec) -> HashMap<&T, usize> where T: PartialEq + Eq + Hash + Clone, { @@ -550,7 +551,11 @@ where let t = observer.last_trace.iter().filter(|x| x.start_tick < worst_instance.1 && x.end_tick > worst_instance.0 ).cloned().collect(); StgFeedback::abbs_in_exec_order(&t) } else { - StgFeedback::abbs_in_exec_order(&observer.last_trace) + if observer.select_task.is_none() { // if nothing was selected, just take the whole trace, otherwise there is nothing interesting here + StgFeedback::abbs_in_exec_order(&observer.last_trace) + } else { + Vec::new() + } } }; if INTEREST_AGGREGATE || INTEREST_ABBPATH { @@ -572,8 +577,8 @@ where if INTEREST_AGGREGATE { // aggegation by sorting, order of states is not relevant let mut _tmp = tmp.clone(); - _tmp.sort(); - let counts = count_occurrences(&_tmp); + _tmp.sort(); // use sort+count, because we need the sorted trace anyways + let counts = count_occurrences_sorted(&_tmp); let mut top_indices = Vec::new(); for (k,c) in counts { if let Some(reference) = feedbackstate.worst_abb_exec_count.get_mut(k) {