-
-
Notifications
You must be signed in to change notification settings - Fork 370
Make input loading fallible in SyncFromDiskStage #3195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f983d80
64ddded
fc5d82a
ce61f00
446502e
ad518d2
1467b9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,9 @@ type String = &'static str; | |
/// Good enough for simple errors, for anything else, use the `alloc` feature. | ||
#[cfg(not(feature = "alloc"))] | ||
macro_rules! format { | ||
($fmt:literal) => {{ $fmt }}; | ||
($fmt:literal) => {{ | ||
$fmt | ||
}}; | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
|
@@ -164,7 +166,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; | |
#[cfg(all(unix, feature = "std"))] | ||
use std::{ | ||
fs::File, | ||
io::{Write, stderr, stdout}, | ||
io::{stderr, stdout, Write}, | ||
os::fd::{AsRawFd, FromRawFd, RawFd}, | ||
panic, | ||
}; | ||
|
@@ -341,6 +343,8 @@ pub enum Error { | |
InvalidCorpus(String, ErrorBacktrace), | ||
/// Error specific to a runtime like QEMU or Frida | ||
Runtime(String, ErrorBacktrace), | ||
/// The `Input` was invalid. | ||
InvalidInput(String, ErrorBacktrace), | ||
} | ||
|
||
impl Error { | ||
|
@@ -369,6 +373,15 @@ impl Error { | |
Error::EmptyOptional(arg.into(), ErrorBacktrace::new()) | ||
} | ||
|
||
/// The `Input` was invalid | ||
#[must_use] | ||
pub fn invalid_input<S>(reason: S) -> Self | ||
where | ||
S: Into<String>, | ||
{ | ||
Error::InvalidInput(reason.into(), ErrorBacktrace::new()) | ||
} | ||
|
||
/// Key not in Map | ||
#[must_use] | ||
pub fn key_not_found<S>(arg: S) -> Self | ||
|
@@ -580,6 +593,10 @@ impl Display for Error { | |
write!(f, "Runtime error: {0}", &s)?; | ||
display_error_backtrace(f, b) | ||
} | ||
Self::InvalidInput(s, b) => { | ||
write!(f, "Encountered an invalid input: {0}", &s)?; | ||
display_error_backtrace(f, b) | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -1088,7 +1105,7 @@ pub fn get_thread_id() -> u64 { | |
#[allow(clippy::cast_sign_loss)] | ||
/// Return thread ID without using TLS | ||
pub fn get_thread_id() -> u64 { | ||
use libc::{SYS_gettid, syscall}; | ||
use libc::{syscall, SYS_gettid}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a cargo fmt update of some sorts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like your fmt is not the same as the CI one |
||
|
||
unsafe { syscall(SYS_gettid) as u64 } | ||
} | ||
|
@@ -1441,7 +1458,7 @@ macro_rules! nonnull_raw_mut { | |
#[allow(missing_docs)] // expect somehow breaks here | ||
pub mod pybind { | ||
|
||
use pyo3::{Bound, PyResult, pymodule, types::PyModule}; | ||
use pyo3::{pymodule, types::PyModule, Bound, PyResult}; | ||
|
||
#[macro_export] | ||
macro_rules! unwrap_me_body { | ||
|
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.
Think this should be warning!
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.
Or maybe info if you think it's expected