You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,38 @@ environment variable `AFL_NO_CFG_FUZZING` to `1` when building.
52
52
[AFLplusplus]: https://aflplus.plus/
53
53
[rust]: https://www.rust-lang.org
54
54
55
+
## Resettable State (`fuzz_with_reset!`)
56
+
57
+
AFL++ persistent mode runs the fuzz target in a loop. Static initialization (e.g., `OnceLock`, `lazy_static`, `once_cell::Lazy`) only executes on the first iteration — subsequent iterations skip those code paths, causing AFL's stability metric to drop.
58
+
59
+
Use `fuzz_with_reset!` to provide a reset closure that clears static state after each iteration.
60
+
61
+
Note: the example uses `Mutex<Option<T>>` instead of `OnceLock`/`OnceCell` because those types do not support resetting out-of-the-box.
// Reset closure: called after each successful iteration
78
+
*CACHE.lock().unwrap() =None;
79
+
});
80
+
}
81
+
```
82
+
83
+
A `fuzz_with_reset_nohook!` variant is also available (like `fuzz_nohook!`, it does not override the panic hook).
84
+
85
+
See [`afl/examples/reset_demo.rs`](afl/examples/reset_demo.rs) for a complete example.
86
+
55
87
## IJON
56
88
57
89
If you want to use [IJON](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/IJON.md) - helping fuzzer coverage through code annotation - then
0 commit comments