Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Fail the task if parsing asan_log files fail (#351)
Browse files Browse the repository at this point in the history
This differentiates parsing ASAN log parse failures from ASAN logs not existing, fixing the first part of #343.
  • Loading branch information
bmc-msft authored Dec 1, 2020
1 parent 7f97c14 commit aef511e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/agent/onefuzz/src/asan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -136,8 +138,8 @@ pub async fn check_asan_string(mut data: String) -> Result<Option<AsanLog>> {
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("...<truncated>");
}
warn!("unable to parse asan log from string: {:?}", data);
Expand All @@ -154,11 +156,11 @@ pub async fn check_asan_path(asan_dir: &Path) -> Result<Option<AsanLog>> {
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("...<truncated>");
}
warn!(
bail!(
"unable to parse asan log {}: {:?}",
file.path().display(),
asan_text
Expand Down

0 comments on commit aef511e

Please sign in to comment.