Skip to content

Commit 6b1c2d8

Browse files
authored
save trace of the found bug (#533)
1 parent d63fe0c commit 6b1c2d8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/evm/cov_stage.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,7 @@ where
167167
.deref()
168168
.borrow_mut()
169169
.save_trace(format!("{}/{}", self.trace_dir, i).as_str());
170-
if let Some(bug_idx) = meta.corpus_idx_to_bug.get(&i.into()) {
171-
for id in bug_idx {
172-
fs::copy(
173-
format!("{}/{}.json", self.trace_dir, i),
174-
format!("{}/bug_{}.json", self.trace_dir, id),
175-
)
176-
.unwrap();
177-
}
178-
}
170+
179171
unsafe {
180172
EVAL_COVERAGE = false;
181173
}

src/fuzzer.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ where
380380
+ HasExecutionResult<Loc, Addr, VS, Out, CI>
381381
+ HasExecutions
382382
+ HasMetadata
383+
+ HasCurrentInputIdx
383384
+ HasRand
384385
+ HasLastReportTime
385386
+ UsesInput<Input = I>,
@@ -578,6 +579,18 @@ where
578579

579580
solution::generate_test(cur_report.clone(), minimized);
580581

582+
unsafe {
583+
for bug_idx in ORACLE_OUTPUT.iter().map(|v| v["bug_idx"].as_u64().unwrap()) {
584+
let src = format!("{}/traces/{}.json", self.work_dir, &state.get_current_input_idx());
585+
let dest = format!("{}/traces/bug_{}.json", self.work_dir, bug_idx);
586+
if std::fs::metadata(&src).is_ok() {
587+
std::fs::copy(&src, &dest).unwrap();
588+
} else {
589+
eprintln!("Source trace {} does not exist", src);
590+
}
591+
}
592+
}
593+
581594
let vuln_file = format!("{}/vuln_info.jsonl", self.work_dir.as_str());
582595
let mut f = OpenOptions::new()
583596
.create(true)

0 commit comments

Comments
 (0)