(
&self,
binary: &Path,
extra_args: Vec<S>,
extra_envs: Vec<(S, S)>,
current_dir: Option<PathBuf>,
stderr: Option<Stdio>,
enough_timeout: bool,
| 245 | } |
| 246 | |
| 247 | pub fn execute<S: AsRef<OsStr> + Debug>( |
| 248 | &self, |
| 249 | binary: &Path, |
| 250 | extra_args: Vec<S>, |
| 251 | extra_envs: Vec<(S, S)>, |
| 252 | current_dir: Option<PathBuf>, |
| 253 | stderr: Option<Stdio>, |
| 254 | enough_timeout: bool, |
| 255 | ) -> Result<Option<ProgramError>> { |
| 256 | let mut child = self.spawn( |
| 257 | binary, |
| 258 | extra_args, |
| 259 | extra_envs, |
| 260 | current_dir, |
| 261 | stderr, |
| 262 | enough_timeout, |
| 263 | ); |
| 264 | |
| 265 | let timeout = if enough_timeout { |
| 266 | crate::config::SANITIZATION_TIMEOUT + 1 |
| 267 | } else { |
| 268 | crate::config::EXECUTION_TIMEOUT + 1 |
| 269 | }; |
| 270 | let timeout = Duration::from_secs(timeout + 3); |
| 271 | let status_code = match child.wait_timeout(timeout)? { |
| 272 | Some(status) => status, |
| 273 | None => { |
| 274 | child.kill()?; |
| 275 | child.wait()?; |
| 276 | return Ok(Some(ProgramError::Hang(format!( |
| 277 | "Execute hang!\n Cmd: {child:#?}" |
| 278 | )))); |
| 279 | } |
| 280 | }; |
| 281 | |
| 282 | if is_exit_normally(status_code.code()) { |
| 283 | return Ok(None); |
| 284 | } |
| 285 | let mut err_msg = String::new(); |
| 286 | if let Some(childerr) = child.stderr.take() { |
| 287 | err_msg = get_child_err(childerr); |
| 288 | } |
| 289 | if err_msg.contains("libFuzzer: timeout") { |
| 290 | return Ok(Some(ProgramError::Hang(err_msg))); |
| 291 | } |
| 292 | Ok(Some(ProgramError::Execute(err_msg))) |
| 293 | } |
| 294 | |
| 295 | pub fn execute_pool(&self, binary: &Path, corpus: &Path) -> Option<ProgramError> { |
| 296 | let cpu_count = max_cpu_count(); |
no test coverage detected