-
Notifications
You must be signed in to change notification settings - Fork 437
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
Code coverage metrics for libFuzzer #41
Comments
Hi Volodia,
On Fri, May 8, 2020 at 1:35 AM Volodia ***@***.***> wrote:
Hi!
I want to better know how experienced ppl measure coverage for fuzzing
nowadays.
By "measure", do you mean measuring for automated purposes (like corpus
expansion during fuzzing)
or for visualization and tracking for human consumption?
There was quite nice method with sancov and libFuzzer -dump_coverage=1
flag in older libFuzzer version, but now deprecated.
I seen that 15mo and 2y ago @kcc <https://github.com/kcc> was involved in
it, so maybe you know what should be done instead?
I haven't managed to make Clang Coverage working with libxml2 fuzzing
example mentioned in 8th lesson of Dor1s/libfuzzer-workshop, so could you
tell me:
1. what is 'rule of thumb' for managing code coverage now?
OSS-Fuzz maintains a separate build of all fuzz targets with Clang
Coverage and provides the coverage dashboard produced by that build.
This is the way we recommend since Clang Coverage has very good
visualization.
1. is there any example of Clang Coverage done with complex library
and fuzzer to see how it was done and learn from it?
All OSS-Fuzz projects (maybe with some minor exceptions) us Clang Coverage.
Perhaps you can send us the description of the problems you are having?
1. which libFuzzer version is used on OSS-Fuzz project?
Current head (maybe with a few weeks delay)
…--kcc
Best regards!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANU24L5CMBUYACCAPB2ILTRQO753ANCNFSM4M374SAQ>
.
|
I think I lacking some basic experience and understanding. Until going deeper I think I can't go through it. Give me one more week and if I could I would be very happy if You could help me with my doubts. Still, thanks for info You gave me, @kcc |
If you have any resources worth reading about this or could throw me any link which works well and generate that lovely graph that would be awesome. |
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html page has the instructions on how generate code coverage report for a single file. If you want to generate code coverage report for a fuzz target linked with some library (e.g. libxml), you need to make sure that all files are compiled with |
I have the same problem. I would like to have a visual coverage, like the tool "gcovr" for gcc does (e.g. in html).
But the problem is that if I use "-fprofile-instr-generate -fcoverage-mapping" together with "-fsanitize=address,fuzzer", after the execution stops (crash or exit) no file ".profraw" is created. I guess the reason is that sanitize breaks the program execution before ".profraw" is created. Any ideas? |
You don't need the address sanitizer enabled to create coverage for you source code. |
Hi @MarcoFalke ! #include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
//int main() {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
printf("Hello World\n");
exit(0);
} And this is the compilation and execution:
Anyway, the file "default.profraw" is created but with size 0:
If I remove "-fsanitize=fuzzer" (and use main() in hello.cc), then the file "default.profraw" is created (and I can see the coverage);
|
@damgut you need to exclude any crash inputs when generating code coverage report. You're right that something breaks the program execution before the .profraw is dumped -- it is a fuzzer crash. To have a good coverage report for your fuzzer, let it run for a while and then use the generation corpora for code coverage generation. It also will be faster to do so.
the |
Thanks @Dor1s, I was trying what you proposed and it works. That means 2 runs: first run until fuzzy crashes and a second run by using the corpus files to generate the coverage in Nevertheless I still have difficulties to generate
Do you know if there is a way to convert this text output in a friendly format (like gcovr which produces an html output) |
|
Thanks @Dor1s and everybody for the fast answers! My last problem was that I've missed the options SummaryI've found 3 different ways to get a coverage when using Using -print_coverage=1Compile and link with Using .profraw fileCompile and link with
The disadvantage here is that coverage.html is a single big file which contain a list of files. There is no summary or statistics. Using gcovrThis is my favorite since the generated html contains different files, one for each source code, together with a summary and nice statistics. Here also 2 runs are needed:
|
Thanks to everyone involved in the discussion! I find this issue really helpful since there seems to be no official document about generating code coverage reports for libfuzzer. Just FYI, I find another tool to get libfuzzer HTML coverage overview https://github.com/vanhauser-thc/libfuzzer-cov |
Hi friends! I have troubles with empty coverage. I tried running the simple @damgut 's example (thank you for the documenting it) #41 (comment) in latest clang docker container and it doesn't produce the COVERAGE. Here is the repro (based on @damgut 's post). create #include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
//int main() {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
printf("Hello World\n");
exit(0);
} Run docker container with latest clang
Compile in it and run
Output that I'm getting
Notice nothing is printed at the end. |
@vors you have three options:
|
@Dor1s oh interesting, thank you for the replay! FWIW this doesn't affect the |
Fuzzing binary now searches for environment variable `FUZZ_CAMPAIGN_MINUTES` to automatically limit, halt execution, and dump gcov data once X minutes have elapsed. This was required to extract gcov data from a fuzzing binary as under normal circumstances manually aborting the execution did not produce any gcov data. google/fuzzing#41
Fuzzing binary now searches for environment variable `FUZZ_CAMPAIGN_MINUTES` to automatically limit, halt execution, and dump gcov data once X minutes have elapsed. This was required to extract gcov data from a fuzzing binary as under normal circumstances manually aborting the execution did not produce any gcov data. google/fuzzing#41
Hi!
I want to better know how experienced ppl measure coverage for fuzzing nowadays.
There was quite nice method with sancov and libFuzzer
-dump_coverage=1
flag in older libFuzzer version, but now deprecated.I seen that 15mo and 2y ago @kcc was involved in it, so maybe you know what should be done instead?
I haven't managed to make Clang Coverage working with libxml2 fuzzing example mentioned in 8th lesson of Dor1s/libfuzzer-workshop, so could you tell me:
Best regards!
The text was updated successfully, but these errors were encountered: