Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't fuzz a crate that catches panic #150

Closed
pedrocr opened this issue Feb 22, 2019 · 2 comments · Fixed by #154
Closed

Can't fuzz a crate that catches panic #150

pedrocr opened this issue Feb 22, 2019 · 2 comments · Fixed by #154

Comments

@pedrocr
Copy link
Contributor

pedrocr commented Feb 22, 2019

My rawloader crate catches panic on file decode to just ignore broken files without having to rewrite all the bounds checks that rust already provides. I'd still like to fuzz it to catch hangs and other causes of crashes. It doesn't seem to be possible right now though because all panics are turned into aborts. Is there a way to avoid that?

@pedrocr
Copy link
Contributor Author

pedrocr commented Feb 22, 2019

Doing something like this fixes it:

#[macro_use]
extern crate afl;

fn main() {
  fuzz!(|data: &[u8]| {
    // Remove the panic hook so we can actually catch panic
    std::panic::set_hook(Box::new(|_| {} ));

    // Fuzz code that catches panics here
  });
}

It seems wasteful to be changing the hook on every call though. Would you take a PR to add an option to fuzz! that disables the hook?

pedrocr added a commit to pedrocr/afl.rs that referenced this issue Feb 22, 2019
If your fuzzing code catches panics somewhere inside its code the hook
would turn those into crashes. Allow disabling the hook by adding a
fuzz_nohook! macro.

Fixes rust-fuzz#150
Fixes rust-fuzz#152
pedrocr added a commit to pedrocr/afl.rs that referenced this issue Feb 22, 2019
If your fuzzing code catches panics somewhere inside its code the hook
would turn those into crashes. Allow disabling the hook by adding a
fuzz_nohook! macro.

Fixes rust-fuzz#150
Fixes rust-fuzz#152
pedrocr added a commit to pedrocr/afl.rs that referenced this issue Feb 22, 2019
If your fuzzing code catches panics somewhere inside its code the hook
would turn those into crashes. Allow disabling the hook by adding a
fuzz_nohook! macro.

Fixes rust-fuzz#150
@HeroicKatora
Copy link

HeroicKatora commented Oct 1, 2019

No longer getting any errors with 0.4.4 with codegen-units=1 in the crate. Remember to manually update if you've added the target according to the guide since creating a bin crate does not exlude Cargo.lock.

Never mind, still present. Now I'm puzzled how it compiled once but doesn't seem to again?

pedrocr added a commit to pedrocr/afl.rs that referenced this issue Oct 6, 2019
If your fuzzing code catches panics somewhere inside its code the hook
would turn those into crashes. Allow disabling the hook by adding a
fuzz_nohook! macro.

Fixes rust-fuzz#150
pedrocr added a commit to pedrocr/afl.rs that referenced this issue Oct 6, 2019
If your fuzzing code catches panics somewhere inside its code the hook
would turn those into crashes. Allow disabling the hook by adding a
fuzz_nohook! macro.

Fixes rust-fuzz#150
pedrocr added a commit to pedrocr/afl.rs that referenced this issue Oct 6, 2019
If your fuzzing code catches panics somewhere inside its code the hook
would turn those into crashes. Allow disabling the hook by adding a
fuzz_nohook! macro.

Fixes rust-fuzz#150
frewsxcv pushed a commit that referenced this issue Oct 12, 2019
If your fuzzing code catches panics somewhere inside its code the hook
would turn those into crashes. Allow disabling the hook by adding a
fuzz_nohook! macro.

Fixes #150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants