Skip to content

Commit

Permalink
Document unwind safety about the fuzzed closure
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulGrandperrin committed Aug 27, 2018
1 parent d4f2a35 commit 629a0d6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ extern "C" {
///
/// For perstistent fuzzing to work, you have to call it ad vita aeternam in an infinite loop.
///
/// The closure is assumed to be unwind-safe, which might be unsafe. For more info, check the
/// [`std::panic::UnwindSafe`] trait.
///
/// ```rust,should_panic
/// # extern crate honggfuzz;
/// # use honggfuzz::fuzz;
Expand Down Expand Up @@ -266,6 +269,8 @@ pub fn fuzz<F>(closure: F) where F: FnOnce(&[u8]) {
// the panic hook.
// If so, the fuzzer will be unable to tell different bugs appart and you will
// only be able to find one bug at a time before fixing it to then find a new one.
// The closure is assumed to be unwind-safe, which might be unsafe. For more info, check the
// [`std::panic::UnwindSafe`] trait.
let did_panic = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
closure(buf);
})).is_err();
Expand Down

0 comments on commit 629a0d6

Please sign in to comment.