From aef511efe8b9860706bbdcef2d4cdfa76daf43c8 Mon Sep 17 00:00:00 2001 From: bmc-msft <41130664+bmc-msft@users.noreply.github.com> Date: Tue, 1 Dec 2020 16:10:59 -0500 Subject: [PATCH] Fail the task if parsing asan_log files fail (#351) This differentiates parsing ASAN log parse failures from ASAN logs not existing, fixing the first part of #343. --- src/agent/onefuzz/src/asan.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/agent/onefuzz/src/asan.rs b/src/agent/onefuzz/src/asan.rs index eec70c0e66..9c658644cc 100644 --- a/src/agent/onefuzz/src/asan.rs +++ b/src/agent/onefuzz/src/asan.rs @@ -7,6 +7,8 @@ use regex::Regex; use std::{collections::HashMap, hash::BuildHasher, path::Path}; use tokio::{fs, stream::StreamExt}; +const ASAN_LOG_TRUNCATE_SIZE: usize = 4096; + #[derive(Clone, Debug)] pub struct AsanLog { text: String, @@ -136,8 +138,8 @@ pub async fn check_asan_string(mut data: String) -> Result> { if asan.is_some() { return Ok(asan); } else { - if data.len() > 1024 { - data.truncate(1024); + if data.len() > ASAN_LOG_TRUNCATE_SIZE { + data.truncate(ASAN_LOG_TRUNCATE_SIZE); data.push_str("..."); } warn!("unable to parse asan log from string: {:?}", data); @@ -154,11 +156,11 @@ pub async fn check_asan_path(asan_dir: &Path) -> Result> { if asan.is_some() { return Ok(asan); } else { - if asan_text.len() > 1024 { - asan_text.truncate(1024); + if asan_text.len() > ASAN_LOG_TRUNCATE_SIZE { + asan_text.truncate(ASAN_LOG_TRUNCATE_SIZE); asan_text.push_str("..."); } - warn!( + bail!( "unable to parse asan log {}: {:?}", file.path().display(), asan_text