Open mgeisler opened 1 year ago
I agree it would be super useful.
There were a couple attempts (https://github.com/rust-fuzz/libfuzzer/pull/33, https://github.com/rust-fuzz/libfuzzer/pull/51) but it seems like the contributors / maintainers lost interest in this.
Hi there,
I'm working on a fuzzer for which I would like to initialize a mutable variable once at the start of the program. I will then use this repeatedly in my fuzzing loop.
Since I believe the fuzzing loop is single threaded, it ought to be simple and safe to setup such a variable at the start of my program. However, due to how
fuzz_target!
expands, I don't think I can do this without using statics? I was thinking to useLLVMFuzzerInitialize
, but then I saw that it's actually used already bylibfuzzer
:slightly_smiling_face: This was also touched upon in #46.I started using a
static mut
with aOnceCell
, but I was immediately told that I'm leaking memory. I was hoping that it would be okay since I expect the static to be dropped as part of the program cleanup when the fuzzing loops stops? However, I see a few hundred messages saying bothand
After all these messages, the fuzzer found a problem and I exited out of the fuzzing loop with a
panic!
.Is there a better way to do expensive initialization of a mutable variable?