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

Faster defaults #231

Merged
merged 11 commits into from Jun 23, 2020
Merged

Faster defaults #231

merged 11 commits into from Jun 23, 2020

Conversation

Shnatsel
Copy link
Member

@Shnatsel Shnatsel commented Jun 20, 2020

  • Default to compiling in release mode with overflow checks and debug assertions enabled
    • Speeds up fuzzing ~10x
  • Add command line option for controlling overflow checks
  • Add command line option for forcing debug mode without optimizations

Resolves #230

@Shnatsel Shnatsel requested a review from fitzgen June 20, 2020 21:56
src/options.rs Outdated Show resolved Hide resolved
src/options.rs Outdated Show resolved Hide resolved
src/project.rs Outdated Show resolved Hide resolved
@fitzgen
Copy link
Member

fitzgen commented Jun 22, 2020

Tests are failing because they look for bins at the target/debug path in various places, so they need to update to target/release.

Also, please add a test for the --dev (ne --debug) flag.

@Shnatsel
Copy link
Member Author

I've fixed everything as requested. Will add a test for --dev shortly.

Do you have any ideas on how to clearly document that the default is --release --debug-assertions --overflow-checks? If I invoke --help it's not clear to me what the build mode will be if no parameters are passed.

Also, there are two changes that might be unexpected for end users:

  • This changes the coverage numbers. Now that a great deal of branches can be optimized out, the reported coverage is much lower (~2000 instead of ~7500 edges for png crate).
  • This changes the default location of the binary. If something was invoking the generated binary directly instead of via cargo fuzz run, that workflow will break.

Should we document this somewhere?

@Shnatsel
Copy link
Member Author

Should be good to go now. Please take another look.

@fitzgen
Copy link
Member

fitzgen commented Jun 22, 2020

Also, there are two changes that might be unexpected for end users:

I'm personally not too concerned with either of these, but we can bump to 0.8.x to be safe. @Manishearth any opinion here?

Do you have any ideas on how to clearly document that the default is --release --debug-assertions --overflow-checks? If I invoke --help it's not clear to me what the build mode will be if no parameters are passed.

Perhaps in the before-help blurb for cargo fuzz run?

cargo-fuzz/src/main.rs

Lines 36 to 43 in 87c36a1

const RUN_BEFORE_HELP: &'static str = "\
The fuzz target name is the same as the name of the fuzz target script in
fuzz/fuzz_targets/, i.e. the name picked when running `cargo fuzz add`.
This will run the script inside the fuzz target with varying inputs until it
finds a crash, at which point it will save the crash input to the artifact
directory, print some output, and exit. Unless you configure it otherwise (see
libFuzzer options below), this will run indefinitely.";

And I think we would also want a custom template for cargo fuzz build like how cargo fuzz run has:

template(LONG_ABOUT_TEMPLATE),

This way we could include the same blurb for both subcommands's help messages.

@nagisa
Copy link
Member

nagisa commented Jun 22, 2020

I'm personally not too concerned with either of these, but we can bump to 0.8.x to be safe.

There's not really a good reason to not bump a "breaking" version number for binaries once there are larger changes to the interface. I vote bump.

@Shnatsel
Copy link
Member Author

I've added a blurb about default build flags to the help text of both cargo fuzz build and cargo fuzz run. I've also added a blurb about sanitizers to cargo fuzz build after-help text, mostly so that I wouldn't have to create yet another help template.

@Manishearth
Copy link
Member

@fitzgen I don't consider these to require a new major version

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @Shnatsel!

@fitzgen fitzgen merged commit ba40b1a into rust-fuzz:master Jun 23, 2020
@Shnatsel Shnatsel deleted the faster-defaults branch June 23, 2020 22:01
@@ -68,6 +72,17 @@ include:
http://llvm.org/docs/LibFuzzer.html#dictionaries\
";

const BUILD_BEFORE_HELP: &'static str = "\
By default fuzz targets are built with optimizations equivalent to
`cargo build --release`, but with debug assertions and overflow checks enabled.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but with debug assertions and overflow checks enabled

which code in this pr is responsible for enabling debug assertions with release mode by default?

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 this pull request may close these issues.

Fuzzing with default settings is much slower than it needs to be
5 participants