rust-fuzz / libfuzzer

Rust bindings and utilities for LLVM’s libFuzzer
Apache License 2.0
208 stars 44 forks source link

Added setup and teardown for fuzzers. #25

Closed nthorne closed 1 year ago

nthorne commented 7 years ago

Added fuzz_setup and fuzz_teardown macros, where setup and teardown lambdas can be detailed in order to e.g. start and stop a server thread that is to be subject to fuzzing.

nagisa commented 7 years ago

The libFuzzer changes should be implemented upstream first. It is desirable to not diverge from upstream libFuzzer at all.

frewsxcv commented 7 years ago

yeah, considering this is a crate for libfuzzer, if libfuzzer (upstream) doesn't support it, seems like it shouldn't be added here. maybe this is something we could add to cargo fuzz? i'm not sure, i don't have any great ideas

nthorne commented 7 years ago

Agree; that was my initial attempt (adding the functionality to cargo fuzz, that is), but I couldn't come up with something that wasn't too ugly. One option could perhaps using a statoc. amd RAII to manage setup/teardown. That way the functionality could be isolated to src/llib.rs. Would you be interested in something along that line, if I manage to whip something up?

frewsxcv commented 7 years ago

Just going to point out that I've read your message, but I really don't know the best course of action for this. @nagisa might have some ideas for this.

djordjepesic1991 commented 1 year ago

Hello, I have a very similar problem. I want to run fuzzer, but before running the fuzzer, I need to execute some preparations, which should be executed only once, before fuzzing itself. Is there any progress with setup & teardown proposal?

fitzgen commented 1 year ago

You can use https://doc.rust-lang.org/nightly/std/sync/struct.Once.html to run one-time initialization code.

fitzgen commented 1 year ago

Going to close this PR as it is quite bit rotted at this point. Feel free to open an issue with any feature requests / more discussion if wanted.