This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Crash repro as task #830
Closed
Closed
Crash repro as task #830
Changes from all commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
5b98a6b
add crash repro as a task
demoray 0d73b9f
experimental live repro using tasks
demoray 202f0ab
Merge branch 'main' into crash-repro-as-task
demoray 5360f03
update from recent SyncedDir changes
demoray b86a44d
run debugger in a loop
demoray 35d8cb7
move heartbeat into loop
demoray c86ecc3
model existing APIs
demoray 6bee24b
Merge branch 'main' into crash-repro-as-task
bmc-msft 0a5d3dd
update webhook docs
demoray 56f7cea
rename input to input_file and add to API
demoray 8c1abf4
add file_name
demoray 9021064
handle task_id expansion
demoray 8429c4b
input file is relative to crashes container
demoray f6fccee
Merge branch 'main' into crash-repro-as-task
bmc-msft cfba620
be explicit in type assignment to help mypy
demoray dc36129
Merge branch 'crash-repro-as-task' of github.com:bmc-msft/onefuzz int…
demoray 3426149
update to support getting node messages
demoray c9f6b16
add context to failures
demoray 1ac3a20
late evaluation of input_path
demoray fa8393f
update refs for Node
demoray f32d962
log task_id for repro task
demoray 2db4a26
formatting
demoray cb208fb
update black
demoray 6d5c6d3
black & flush out debugger cmds
demoray 30ec432
add logging to commands to debug
demoray 026de37
compare against an Instant since the sleep isn't being polled
demoray 5b59cb3
wait for proxy IP
demoray acedb7b
update scalesetproxy log level
demoray dac9212
only one yield
demoray 259c974
remove debug prints
demoray 7b03e64
Merge branch 'main' into crash-repro-as-task
bmc-msft 3621e5a
Merge branch 'main' into crash-repro-as-task
bmc-msft 72afa4e
Merge branch 'main' into crash-repro-as-task
demoray 40c4b19
remove extra info
demoray cad9c67
Merge branch 'main' into crash-repro-as-task
bmc-msft 3dd39a5
Merge branch 'main' into crash-repro-as-task
demoray 750fcbb
continued updates
demoray db09ffc
Merge branch 'main' into crash-repro-as-task
bmc-msft 3610c16
monitor for failed tasks during initial connection.
demoray f3b7013
provide more details in add_ssh_key failures
demoray 2faf328
fix missing comma
demoray 88e12a3
Merge branch 'main' into crash-repro-as-task
bmc-msft 19a64be
Merge branch 'main' into crash-repro-as-task
bmc-msft 28bdb2a
Merge branch 'main' into crash-repro-as-task
bmc-msft 68bba3a
Merge branch 'main' into crash-repro-as-task
bmc-msft 61b6f85
Merge branch 'main' into crash-repro-as-task
bmc-msft 0cea4c6
Merge branch 'main' into crash-repro-as-task
bmc-msft cc99ca4
use self.success for repro tasks
demoray 9a230d0
set ssh keys only once
demoray 57e9cb0
add specific logging for set_halt
demoray 333ebf3
address issue deleting nodes that fail heartbeats
demoray 5cbee79
clarify log message
demoray b8dec49
address feedback
demoray 9df75b7
save more details to the failure context
demoray f4f16b1
Merge branch 'main' into crash-repro-as-task
bmc-msft cfbf3a7
handle proxies not deleting
demoray 96d1d07
Merge branch 'main' into crash-repro-as-task
bmc-msft e3a1b45
Merge branch 'main' into crash-repro-as-task
bmc-msft 952854d
Merge branch 'main' into crash-repro-as-task
bmc-msft 92978a5
Merge branch 'crash-repro-as-task' of github.com:bmc-msft/onefuzz int…
demoray 8f9ca4d
explain which repro is being tested
demoray e41c286
check task in the wait loop callbacks
demoray 59a5867
Merge branch 'main' into crash-repro-as-task
bmc-msft 0e05b51
add stop_after_use feature similar to delete_after_use for old repro
demoray 02fa8b6
reduce cdb interaction until we connect in
demoray 8453d61
Merge branch 'main' into crash-repro-as-task
bmc-msft dc28d3c
rename agent task to analysis_single
demoray b66d66f
Merge branch 'crash-repro-as-task' of github.com:bmc-msft/onefuzz int…
demoray bfba12e
fix command info
demoray fc54ab4
add an optional initial delay for heartbeats
demoray 55baef0
Merge branch 'add-heartbeat-initialization-delay' into crash-repro-as…
demoray 5cf835a
set initialization delay
demoray d03f034
wait for heartbeats before starting the task
demoray 5a82733
log the signalr event
demoray 17e613d
Merge branch 'main' into crash-repro-as-task
demoray de83031
fix merge issue
demoray 16312af
Merge branch 'main' into crash-repro-as-task
bmc-msft a09e4c9
Merge branch 'main' into crash-repro-as-task
bmc-msft 17f60c9
Merge branch 'main' into crash-repro-as-task
bmc-msft 8bb2400
fix incorrect wait cmd
demoray 9a5393b
launch repros iteratively
demoray 91a8539
only remove SYSTEM if it's there
demoray ba0aacb
fix to_string
demoray e5f3d5e
remove debugging
demoray d649455
Merge branch 'main' into crash-repro-as-task
bmc-msft 3c32292
Apply suggestions from code review
bmc-msft 880050a
Merge branch 'main' into crash-repro-as-task
bmc-msft 67b32ab
Merge branch 'main' into crash-repro-as-task
demoray cee87dc
remove stray }
demoray 474c19a
Merge branch 'main' into crash-repro-as-task
bmc-msft 31de28e
Merge branch 'main' into crash-repro-as-task
bmc-msft d410653
Merge branch 'main' into crash-repro-as-task
bmc-msft add906f
Merge branch 'main' into crash-repro-as-task
bmc-msft 5d8b57a
Merge branch 'main' into crash-repro-as-task
bmc-msft 8f40e99
Merge branch 'main' into crash-repro-as-task
bmc-msft 1979d88
Merge branch 'main' into crash-repro-as-task
bmc-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
// Licensed under the MIT License. | ||
|
||
pub mod generic; | ||
pub mod single; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use crate::tasks::{config::CommonConfig, heartbeat::HeartbeatSender}; | ||
use anyhow::{Context, Result}; | ||
use onefuzz::{expand::Expand, fs::set_executable, process::monitor_process, syncdir::SyncedDir}; | ||
use serde::Deserialize; | ||
use std::time::Duration; | ||
use std::{collections::HashMap, path::PathBuf, process::Stdio}; | ||
use tokio::process::Command; | ||
|
||
const INITIAL_DELAY: Duration = Duration::from_millis(1); | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct Config { | ||
pub analyzer_exe: String, | ||
pub analyzer_options: Vec<String>, | ||
pub analyzer_env: HashMap<String, String>, | ||
|
||
pub target_exe: PathBuf, | ||
pub target_options: Vec<String>, | ||
pub crashes: SyncedDir, | ||
pub input_file: String, | ||
|
||
pub tools: Option<SyncedDir>, | ||
|
||
#[serde(flatten)] | ||
pub common: CommonConfig, | ||
} | ||
|
||
pub async fn run(config: Config) -> Result<()> { | ||
config | ||
.crashes | ||
.init_pull() | ||
.await | ||
.context("unable to sync crashes")?; | ||
if let Some(tools) = &config.tools { | ||
tools.init_pull().await.context("unable to sync tools")?; | ||
set_executable(&tools.local_path) | ||
.await | ||
.context("unable to set tools as executable")?; | ||
} | ||
|
||
run_tool(&config).await | ||
} | ||
|
||
pub async fn run_tool(config: &Config) -> Result<()> { | ||
let heartbeat = config.common.init_heartbeat(Some(INITIAL_DELAY)).await?; | ||
let expand = Expand::new() | ||
.target_exe(&config.target_exe) | ||
.target_options(&config.target_options) | ||
.analyzer_exe(&config.analyzer_exe) | ||
.analyzer_options(&config.analyzer_options) | ||
.crashes(&config.crashes.local_path) | ||
.set_optional_ref(&config.tools, |tester, key| { | ||
tester.tools_dir(&key.local_path) | ||
}) | ||
.setup_dir(&config.common.setup_dir) | ||
.job_id(&config.common.job_id) | ||
.task_id(&config.common.task_id) | ||
.set_optional_ref(&config.common.microsoft_telemetry_key, |tester, key| { | ||
tester.microsoft_telemetry_key(&key) | ||
}) | ||
.set_optional_ref(&config.common.instance_telemetry_key, |tester, key| { | ||
tester.instance_telemetry_key(&key) | ||
}) | ||
.set_optional_ref( | ||
&config.crashes.remote_path.clone().and_then(|u| u.account()), | ||
|tester, account| tester.crashes_account(account), | ||
) | ||
.set_optional_ref( | ||
&config | ||
.crashes | ||
.remote_path | ||
.clone() | ||
.and_then(|u| u.container()), | ||
|tester, container| tester.crashes_container(container), | ||
); | ||
|
||
let input_path = expand | ||
.evaluate_value(format!("{{crashes}}/{}", config.input_file)) | ||
.context("unable to expand input_path")?; | ||
let expand = expand.input_path(input_path); | ||
|
||
let analyzer_path = expand | ||
.evaluate_value(&config.analyzer_exe) | ||
.context("expanding analyzer_exe failed")?; | ||
|
||
loop { | ||
let mut cmd = Command::new(&analyzer_path); | ||
cmd.kill_on_drop(true) | ||
.env_remove("RUST_LOG") | ||
.stdin(Stdio::null()) | ||
.stdout(Stdio::piped()) | ||
.stderr(Stdio::piped()); | ||
|
||
for arg in expand.evaluate(&config.analyzer_options)? { | ||
cmd.arg(arg); | ||
} | ||
|
||
for (k, v) in &config.analyzer_env { | ||
cmd.env( | ||
k, | ||
expand | ||
.evaluate_value(v) | ||
.context("expanding analyzer_env failed")?, | ||
); | ||
} | ||
|
||
info!("analyzing input with {:?}", cmd); | ||
let output = cmd | ||
.spawn() | ||
.with_context(|| format!("analyzer failed to start: {}", analyzer_path))?; | ||
|
||
heartbeat.alive(); | ||
|
||
// while we monitor the runtime of the debugger, we don't fail the task if | ||
// the debugger exits non-zero. This frequently happens during normal use of | ||
// debuggers. | ||
monitor_process(output, "crash-repro".to_string(), true, None) | ||
.await | ||
.ok(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we be storing the logs of the analysis ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
monitor_process
logs stdout and stderr to application insights.