Skip to content

Commit

Permalink
fix: catch LLVM subprocess crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgar2017 committed Jul 11, 2024
1 parent 1860fd8 commit 7e6c631
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ where
let result = process
.wait_with_output()
.unwrap_or_else(|error| panic!("{executable:?} subprocess output reading: {error:?}"));
era_compiler_common::deserialize_from_slice(result.stdout.as_slice())
.unwrap_or_else(|error| panic!("{executable:?} subprocess stdout parsing: {error:?}"))

if result.status.code() != Some(era_compiler_common::EXIT_CODE_SUCCESS) {
let message = format!(
"{executable:?} subprocess failed with exit code {:?}:\n{}\n{}",
result.status.code(),
String::from_utf8_lossy(result.stdout.as_slice()),
String::from_utf8_lossy(result.stderr.as_slice()),
);
return Err(SolcStandardJsonOutputError::new_error(message, None, None));
}

match era_compiler_common::deserialize_from_slice(result.stdout.as_slice()) {
Ok(output) => output,
Err(error) => {
panic!(
"{executable:?} subprocess stdout parsing error: {error:?}\n{}\n{}",
String::from_utf8_lossy(result.stdout.as_slice()),
String::from_utf8_lossy(result.stderr.as_slice()),
);
}
}
}

0 comments on commit 7e6c631

Please sign in to comment.