libfuzzer icon indicating copy to clipboard operation
libfuzzer copied to clipboard

Added setup and teardown for fuzzers.

Open nthorne opened this issue 7 years ago • 4 comments

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.

nthorne avatar May 03 '17 20:05 nthorne

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

nagisa avatar May 03 '17 20:05 nagisa

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

frewsxcv avatar May 14 '17 21:05 frewsxcv

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?

nthorne avatar May 15 '17 06:05 nthorne

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.

frewsxcv avatar May 24 '17 02:05 frewsxcv

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?

djordjepesic1991 avatar Aug 18 '22 13:08 djordjepesic1991

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

fitzgen avatar Aug 18 '22 17:08 fitzgen

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.

fitzgen avatar Aug 18 '22 17:08 fitzgen