-
Notifications
You must be signed in to change notification settings - Fork 129
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
WIP: Add fuzzer tests #143
base: main
Are you sure you want to change the base?
Conversation
2f9b316
to
4602c2d
Compare
That's awesome, thank you! I think it would probably be better to return errors about malformed input in those cases rather than rely on assertions (cc @jasonrhansen), which would also let you fuzz better. Running fuzzing only on nightly seems fine to me! |
As for the assertion in if self.event_filter.is_none() {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"no event filter found while processing input",
));
} |
In if self.stack.is_empty() {
warn!("on_stack_end called with an empty stack");
return;
} |
@jonhoo Do you want to run fuzzing on CI? Cirrus CI is only used for FreeBSD, the rest is tested on Azure, which uses some predefined templates? I could add |
I think we probably only need to run fuzzing on one of the CIs. Probably Azure. What you'll want to do is add another "stage" before the empty line before the line that reads - stage: fuzz
displayName: fuzzing tests
jobs:
- job: fuzz
displayName: cargo +nightly fuzz
pool:
vmImage: ubuntu-16.04
steps:
- template: azure/install-rust.yml@templates
parameters:
rust: nightly
- checkout: self
submodules: recursive
- script: cargo install cargo-fuzz
displayName: Install cargo fuzz
- script: cargo fuzz run <targets>
displayName: Run fuzzer |
Is Azure currently integrated into this GitHub (like for example in |
Looks like it was misconfigured in some way — should be fixed now! You may want to merge with master. |
Ok, I rebased onto master. However there is a problem with |
Ah, yes, that seems to be crossbeam-rs/crossbeam#404. |
Looks like coverage sometimes crashes due to xd009642/tarpaulin#190. Since your fuzzing stage now comes after coverage testing, it might not even run if that triggers. Try adding the following to the new stage you added: dependsOn: test |
Now we're getting somewhere! At least one fuzz failure: |
Cool :) Do you have access to the artifact directory? The test was written to |
Hmm, I think for that you need to add another step at the end that publishes a Pipeline Artifact: - publish: $(System.DefaultWorkingDirectory)/fuzz/artifacts/
condition: failed()
artifact: fuzz I think that step should still execute even if the previous once failed (due to the |
Uhh, the terminology here is atrocious, multiple types of artifacts.. in GitLab it's pretty easy, in Azure I'm a bit lost :-) I think that you might be able to click on the pipeline run and then it shows I half expect that the |
Huh, that seems to not even have triggered a build...? :/ |
Hi, I wanted to experiment with fuzzing in Rust, so I thought that I would start with this crate, since you have suggested that some fuzz tests would be nice (#63).
I simply added
cargo fuzz
and created a single fuzz target for eachCollapse
implemetation. Since the trait is so simple, this should be enough. Is that ok?We should also define what do you actually consider a bug in the library and what do you consider a "bug" in the input. For example immediately after I started fuzzing
perf
, it crashed, because it fails on an assertion (https://github.com/jonhoo/inferno/blob/master/src/collapse/perf.rs#L173) if the input (file) is empty. For cmd usage this is probably not that much different from a controlled notification about a bad input with aResult
, but for a library usage a crash like that on an invalid input is probably not something that you want. If I comment out the assert, the fuzzer doesn't seem to find any other crash inperf
, so maybe the assert is superfluous?I didn't run the fuzzers for long, they also found one other crash in
dtrace
(related to overflow in subtraction).Cargo fuzz reguires nightly though, so the fuzz tests would have to be executed in CI using
nightly
.