From 3d1f0bfb0d277fa9f4fb5e2ad3138b26a556555e Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Wed, 25 Sep 2024 15:45:48 +0200 Subject: [PATCH] Fix CI (#2557) * libafl-fuzz: fix id collision in Solution corpora * libafl-fuzz: use dynamic map size * print * use PROJECT_DIR * tmate * idk * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * a' --------- Co-authored-by: aarnav --- fuzzers/others/libafl-fuzz/Makefile.toml | 2 +- fuzzers/others/libafl-fuzz/src/corpus.rs | 14 ++++++++------ fuzzers/others/libafl-fuzz/src/fuzzer.rs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fuzzers/others/libafl-fuzz/Makefile.toml b/fuzzers/others/libafl-fuzz/Makefile.toml index 4e9105b031..1c7401072d 100644 --- a/fuzzers/others/libafl-fuzz/Makefile.toml +++ b/fuzzers/others/libafl-fuzz/Makefile.toml @@ -110,7 +110,7 @@ script = ''' # cmplog TODO: AFL_BENCH_UNTIL_CRASH=1 instead of timeout 15s AFL_LLVM_CMPLOG=1 AFL_PATH=${AFL_DIR} ${AFL_CC_PATH} ./test/test-cmplog.c -o ./test/out-cmplog AFL_CORES=1 timeout 5 ${FUZZER} -Z -l 3 -m 0 -V30 -i ./test/seeds_cmplog -o ./test/output-cmplog -c 0 ./test/out-cmplog || true -test -n "$( ls ./test/output-cmplog/fuzzer_main/crashes/id:0000* 2>/dev/null )" || { +test -n "$( ls ${PROJECT_DIR}/test/output-cmplog/fuzzer_main/hangs/id:0000* ${PROJECT_DIR}/test/output-cmplog/fuzzer_main/crashes/id:0000*)" || { echo "No crashes found" exit 1 } diff --git a/fuzzers/others/libafl-fuzz/src/corpus.rs b/fuzzers/others/libafl-fuzz/src/corpus.rs index 8d3afae1bd..66fa80552f 100644 --- a/fuzzers/others/libafl-fuzz/src/corpus.rs +++ b/fuzzers/others/libafl-fuzz/src/corpus.rs @@ -6,9 +6,9 @@ use std::{ }; use libafl::{ - corpus::{Corpus, Testcase}, + corpus::{Corpus, CorpusId, Testcase}, inputs::BytesInput, - state::{HasCorpus, HasExecutions, HasStartTime}, + state::{HasCorpus, HasExecutions, HasSolutions, HasStartTime}, Error, }; use libafl_bolts::current_time; @@ -19,9 +19,9 @@ use nix::{ use crate::{fuzzer::LibaflFuzzState, OUTPUT_GRACE}; -pub fn generate_base_filename(state: &mut LibaflFuzzState) -> String { +pub fn generate_base_filename(state: &mut LibaflFuzzState, id: CorpusId) -> String { + let id = id.0; let is_seed = state.must_load_initial_inputs(); - let id = state.corpus().peek_free_id().0; let name = if is_seed { // TODO set orig filename format!("id:{id:0>6},time:0,execs:0,orig:TODO",) @@ -46,7 +46,8 @@ pub fn set_corpus_filepath( testcase: &mut Testcase, _fuzzer_dir: &Path, ) -> Result<(), Error> { - let mut name = generate_base_filename(state); + let id = state.corpus().peek_free_id(); + let mut name = generate_base_filename(state, id); if testcase.hit_feedbacks().contains(&Cow::Borrowed("edges")) { name = format!("{name},+cov"); } @@ -64,7 +65,8 @@ pub fn set_solution_filepath( ) -> Result<(), Error> { // sig:0SIGNAL // TODO: verify if 0 time if objective found during seed loading - let mut filename = generate_base_filename(state); + let id = state.solutions().peek_free_id(); + let mut filename = generate_base_filename(state, id); let mut dir = "crashes"; if testcase .hit_objectives() diff --git a/fuzzers/others/libafl-fuzz/src/fuzzer.rs b/fuzzers/others/libafl-fuzz/src/fuzzer.rs index 3bd20c29e8..1c9e982627 100644 --- a/fuzzers/others/libafl-fuzz/src/fuzzer.rs +++ b/fuzzers/others/libafl-fuzz/src/fuzzer.rs @@ -252,7 +252,7 @@ where // Finalize and build our Executor let mut executor = executor_builder - .build(tuple_list!(time_observer, edges_observer)) + .build_dynamic_map(edges_observer, tuple_list!(time_observer)) .unwrap(); let queue_dir = fuzzer_dir.join("queue");