-
Notifications
You must be signed in to change notification settings - Fork 47
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
Introduce LLVMFuzzerInitialize support #128
base: main
Are you sure you want to change the base?
Introduce LLVMFuzzerInitialize support #128
Conversation
- Added `example_init` to demonstrate the use of initialization code with the `fuzz_target!` macro. - Updated `fuzz_target!` macro to support an `init` parameter for executing initialization code before fuzzing. - Updated CI script to build and run the new example.
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.
Thanks for doing this before I got around to it! Some questions/suggestions I had while skimming the diff. I'm not a maintainer, so this doesn't carry any weight one way or another, but I hope they're still useful.
@@ -198,9 +185,31 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize | |||
/// `"arbitrary-derive"` cargo feature. | |||
#[macro_export] | |||
macro_rules! fuzz_target { | |||
(|$bytes:ident| $body:expr) => { | |||
(init: $init:expr, |$bytes:ident| $body:expr) => { |
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.
Using $init:expr
matches the existing behavior for $body
but I'm not sure if that's desirable. It permits all sorts of expressions, including those that return values, which may be misleading. This is code that's executed for side-effects, so $init:stmt
seems more appropriate. However, non-block statements look strange to me in this position (fuzz_target!(init: let x = 0, |data| {})
without semicolon would be valid but meaningless). So maybe enforce that it's a block with $init:block
and expand to let _: () = $init;
so that it's required to not return anything meaningful?
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.
I'll wait and see what the maintainers have to say, but I get your point, still I don't have a preference.
example_init
to demonstrate the use of initialization code with thefuzz_target!
macro.fuzz_target!
macro to support aninit
parameter for executing initialization code before fuzzing.Should I update any doc with init usage example?
Is the example good enough? Maybe an example using
static
would be more meaningful.Close after merge:
fuzz_target!
code #110