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

Fuzzing and rust coverage #5595

Closed
wants to merge 2 commits into from

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/4125

Describe changes:

  • do not rebuild rust std when instrumenting for coverage (as both seem incompatible)
  • fuzz driver accepts directories as well as single files now

TL;DR
To get coverage report including rust with oss-fuzz, we will also need rustc changes, and oss-fuzz changes
To get this manually is possible, cf below

To get coverage, I compile with

export RUSTFLAGS="$RUSTFLAGS -Zinstrument-coverage"
export CFLAGS="-g -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fprofile-instr-generate -fcoverage-mapping -pthread -fsanitize=fuzzer-no-link"
export CXXFLAGS="-g -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fprofile-instr-generate -fcoverage-mapping -pthread -fsanitize=fuzzer-no-link -stdlib=libc++"

I also run in rust subdirectory

abspath=`cargo metadata | jq -r '.workspace_root'`
export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix src=$abspath/src"

to get the absolute file paths for suricata's crate, so that llvm-cov can generate a nice report

You need some fresh rust nightly compiler and llvm 10
For LLVM 11 and 12, rust compiler is not ready yet cf rust-lang/rust#79365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant