diff --git a/src/agent/Cargo.lock b/src/agent/Cargo.lock index a2fe77b872..5e1230f4ed 100644 --- a/src/agent/Cargo.lock +++ b/src/agent/Cargo.lock @@ -1432,7 +1432,6 @@ version = "0.1.0" dependencies = [ "anyhow", "atexit", - "coverage", "debugger", "fnv", "hex", @@ -2988,6 +2987,7 @@ dependencies = [ "async-trait", "backoff", "base64", + "bincode", "bytes", "derivative", "flume", diff --git a/src/agent/input-tester/Cargo.toml b/src/agent/input-tester/Cargo.toml index 27d872b2e4..0ba7d7155f 100644 --- a/src/agent/input-tester/Cargo.toml +++ b/src/agent/input-tester/Cargo.toml @@ -8,7 +8,6 @@ license = "MIT" [dependencies] anyhow = "1.0" atexit = { path = "../atexit" } -coverage = { path = "../coverage" } debugger = { path = "../debugger" } fnv = "1.0" hex = "0.4" diff --git a/src/agent/input-tester/src/crash_detector.rs b/src/agent/input-tester/src/crash_detector.rs index 10b863ce14..66bc3f6189 100644 --- a/src/agent/input-tester/src/crash_detector.rs +++ b/src/agent/input-tester/src/crash_detector.rs @@ -14,11 +14,7 @@ use std::{ }; use anyhow::Result; -use coverage::{ - block::{windows::Recorder as BlockCoverageRecorder, CommandBlockCov}, - cache::ModuleCache, -}; -use debugger::{BreakpointId, DebugEventHandler, Debugger, ModuleLoadInfo}; +use debugger::{DebugEventHandler, Debugger}; use log::{debug, error, trace}; use win_util::{ pipe_handle::{pipe, PipeReaderNonBlocking}, @@ -48,7 +44,6 @@ pub struct DebuggerResult { pub stdout: String, pub stderr: String, pub debugger_output: String, - pub coverage: Option, } impl DebuggerResult { @@ -58,7 +53,6 @@ impl DebuggerResult { stdout: String, stderr: String, debugger_output: String, - coverage: Option, ) -> Self { DebuggerResult { exceptions, @@ -66,7 +60,6 @@ impl DebuggerResult { stdout, stderr, debugger_output, - coverage, } } @@ -125,7 +118,7 @@ impl DebuggerResult { } } -struct CrashDetectorEventHandler<'a> { +struct CrashDetectorEventHandler { start_time: Instant, max_duration: Duration, ignore_first_chance_exceptions: bool, @@ -137,17 +130,15 @@ struct CrashDetectorEventHandler<'a> { stderr_buffer: Vec, debugger_output: String, exceptions: Vec, - coverage: Option>, } -impl<'a> CrashDetectorEventHandler<'a> { +impl CrashDetectorEventHandler { pub fn new( stdout: PipeReaderNonBlocking, stderr: PipeReaderNonBlocking, ignore_first_chance_exceptions: bool, start_time: Instant, max_duration: Duration, - coverage: Option>, ) -> Self { Self { start_time, @@ -161,7 +152,6 @@ impl<'a> CrashDetectorEventHandler<'a> { stderr_buffer: vec![], debugger_output: String::new(), exceptions: vec![], - coverage, } } } @@ -191,7 +181,7 @@ fn is_vcpp_notification(exception: &EXCEPTION_DEBUG_INFO, target_process_handle: false } -impl<'a> DebugEventHandler for CrashDetectorEventHandler<'a> { +impl DebugEventHandler for CrashDetectorEventHandler { fn on_exception( &mut self, debugger: &mut Debugger, @@ -272,44 +262,16 @@ impl<'a> DebugEventHandler for CrashDetectorEventHandler<'a> { debugger.quit_debugging(); } } - - fn on_create_process(&mut self, dbg: &mut Debugger, module: &ModuleLoadInfo) { - if let Some(coverage) = &mut self.coverage { - if let Err(err) = coverage.on_create_process(dbg, module) { - error!("error recording coverage on create process: {:?}", err); - dbg.quit_debugging(); - } - } - } - - fn on_load_dll(&mut self, dbg: &mut Debugger, module: &ModuleLoadInfo) { - if let Some(coverage) = &mut self.coverage { - if let Err(err) = coverage.on_load_dll(dbg, module) { - error!("error recording coverage on load DLL: {:?}", err); - dbg.quit_debugging(); - } - } - } - - fn on_breakpoint(&mut self, dbg: &mut Debugger, bp: BreakpointId) { - if let Some(coverage) = &mut self.coverage { - if let Err(err) = coverage.on_breakpoint(dbg, bp) { - error!("error recording coverage on breakpoint: {:?}", err); - dbg.quit_debugging(); - } - } - } } /// This function runs the application under a debugger to detect any crashes in /// the process or any children processes. -pub fn test_process<'a>( +pub fn test_process( app_path: impl AsRef, args: &[impl AsRef], env: &HashMap, max_duration: Duration, ignore_first_chance_exceptions: bool, - cache: Option<&'a mut ModuleCache>, ) -> Result { debug!("Running: {}", logging::command_invocation(&app_path, args)); @@ -328,8 +290,6 @@ pub fn test_process<'a>( command.env(k, v); } - let filter = coverage::code::CmdFilter::default(); - let recorder = cache.map(|c| BlockCoverageRecorder::new(c, filter)); let start_time = Instant::now(); let mut event_handler = CrashDetectorEventHandler::new( stdout_reader, @@ -337,7 +297,6 @@ pub fn test_process<'a>( ignore_first_chance_exceptions, start_time, max_duration, - recorder, ); let (mut debugger, mut child) = Debugger::init(command, &mut event_handler)?; debugger.run(&mut event_handler)?; @@ -365,7 +324,6 @@ pub fn test_process<'a>( String::from_utf8_lossy(&output.stdout).to_string(), String::from_utf8_lossy(&output.stderr).to_string(), event_handler.debugger_output, - event_handler.coverage.map(|r| r.into_coverage()), )) } @@ -407,7 +365,6 @@ mod tests { &HashMap::default(), $timeout, /*ignore first chance exceptions*/ true, - None, ) .unwrap() }}; diff --git a/src/agent/input-tester/src/lib.rs b/src/agent/input-tester/src/lib.rs index ab9f12cee8..acdf8d2f41 100644 --- a/src/agent/input-tester/src/lib.rs +++ b/src/agent/input-tester/src/lib.rs @@ -44,7 +44,6 @@ pub fn run( max_run_s, ignore_first_chance_exceptions, app_verifier_tests, - coverage::cache::ModuleCache::default(), )?; tester.set_appverifier(AppVerifierState::Enabled)?; diff --git a/src/agent/input-tester/src/tester.rs b/src/agent/input-tester/src/tester.rs index 5fcce19b82..44187a8c99 100644 --- a/src/agent/input-tester/src/tester.rs +++ b/src/agent/input-tester/src/tester.rs @@ -14,12 +14,11 @@ use std::{ fs, io::Write, path::{Path, PathBuf}, - sync::{Arc, RwLock}, + sync::Arc, time::Duration, }; use anyhow::{Context, Result}; -use coverage::cache::ModuleCache; use log::{error, info, trace, warn}; use num_cpus; use rayon::{prelude::*, ThreadPoolBuilder}; @@ -71,7 +70,6 @@ pub struct Tester { ignore_first_chance_exceptions: bool, appverif_controller: Option, bugs_found_dir: PathBuf, - module_cache: RwLock, } impl Tester { @@ -83,7 +81,6 @@ impl Tester { max_run_s: u64, ignore_first_chance_exceptions: bool, app_verifier_tests: Option>, - module_cache: ModuleCache, ) -> Result> { let mut bugs_found_dir = output_dir.to_path_buf(); bugs_found_dir.push("bugs_found"); @@ -118,7 +115,6 @@ impl Tester { max_run_s, ignore_first_chance_exceptions, bugs_found_dir, - module_cache: RwLock::new(module_cache), })) } @@ -126,18 +122,12 @@ impl Tester { pub fn test_application(&self, input_path: impl AsRef) -> Result { let app_args = args_with_input_file_applied(&self.driver_args, &input_path)?; - let mut module_cache = self - .module_cache - .write() - .map_err(|err| anyhow::format_err!("{:?}", err))?; - crash_detector::test_process( &self.driver, &app_args, &self.driver_env, Duration::from_secs(self.max_run_s), self.ignore_first_chance_exceptions, - Some(&mut *module_cache), ) .and_then(|result| { let result = InputTestResult::new(result, PathBuf::from(input_path.as_ref())); diff --git a/src/agent/onefuzz/src/input_tester.rs b/src/agent/onefuzz/src/input_tester.rs index ec4375455d..66f119df0e 100644 --- a/src/agent/onefuzz/src/input_tester.rs +++ b/src/agent/onefuzz/src/input_tester.rs @@ -147,7 +147,6 @@ impl<'a> Tester<'a> { &env, self.timeout, IGNORE_FIRST_CHANCE_EXCEPTIONS, - None, )?; let crash = if let Some(exception) = report.exceptions.last() {