MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / current_state_is_favored

Function current_state_is_favored

hail-fuzz/src/queue.rs:506–534  ·  view source on GitHub ↗

Determine whether the current input is smaller than an existing entry in the queue that is favored for a particular bit.

(
    state: &mut State,
    store: &mut CorpusStore<MultiStream>,
)

Source from the content-addressed store, hash-verified

504/// Determine whether the current input is smaller than an existing entry in the queue that is
505/// favored for a particular bit.
506pub(crate) fn current_state_is_favored(
507 state: &mut State,
508 store: &mut CorpusStore<MultiStream>,
509) -> bool {
510 let len = state.input.total_bytes();
511 let mut improvement = false;
512 for idx in &state.hit_coverage {
513 let best = store.coverage_hits[idx]
514 .iter()
515 .map(|id| (id, &store.test_cases[*id].metadata))
516 .min_by_key(|(_, metadata)| metadata.len);
517
518 let Some((id, metadata)) = best
519 else {
520 tracing::warn!("No existing input for {idx:#x} but input was not considered new");
521 return true;
522 };
523
524 if len as f32 * 1.1f32 < metadata.len as f32 {
525 tracing::debug!(
526 "new input length {len} is better than existing best input id={id}, len={}, for bit={idx:#x}",
527 metadata.len
528 );
529 state.new_bits.push(*idx);
530 improvement = true;
531 }
532 }
533 improvement
534}
535
536static GLOBAL_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
537

Callers 1

check_exit_stateMethod · 0.85

Calls 1

total_bytesMethod · 0.80

Tested by

no test coverage detected