This is an archive of the discontinued LLVM Phabricator instance.

Enable libFuzzer's afl_driver to append stderr to a file.
ClosedPublic

Authored by metzman on Jun 9 2016, 11:41 AM.

Details

Summary

[libFuzzer] Enable afl_driver to append stderr to a user specified file.

Append stderr of afl_driver to the file specified by the environmental variable
AFL_DRIVER_STDERR_DUPLICATE_FILENAME if it is set. This lets users see outputs
on crashes without rerunning crashing test cases (which won't work for crashes
that are difficult to reproduce). Before this patch, stderr would only be sent to afl-fuzz
and users would have no way of seeing it.

Diff Detail

Repository
rL LLVM

Event Timeline

metzman updated this revision to Diff 60213.Jun 9 2016, 11:41 AM
metzman retitled this revision from to Enable libFuzzer's afl_driver to append stderr to a file..
metzman updated this object.
metzman added reviewers: llvm-commits, kcc, aizatsky.
kcc added inline comments.Jun 9 2016, 12:00 PM
lib/Fuzzer/test/FuzzerUnittest.cpp
455 ↗(On Diff #60213)

This test does not belong here.
Make it a separate lit-style test (like all other libFuzzer tests).
As the result, you will not need afl/afl_driver.h

metzman updated this revision to Diff 60356.Jun 10 2016, 8:20 AM

Remove afl_driver.h, move tests to afl-driver.test

kcc edited edge metadata.Jun 13 2016, 12:03 PM

Please upload the patches with context (use the 'arc' command line tool).

lib/Fuzzer/afl/afl_driver.cpp
64 ↗(On Diff #60356)

static void maybe_duplicate_stderr() {

lib/Fuzzer/test/afl-driver.test
1 ↗(On Diff #60356)

I afraid it's not that simple.
You can not expect clang++ to be in PATH, so you actually need to have a cmake
rule to build this binary

8 ↗(On Diff #60356)

and of course you can not expect ~/llvm to exist

metzman updated this revision to Diff 60698.Jun 14 2016, 9:58 AM
metzman edited edge metadata.

Build the test binary using cmake and remove use of a hardcoded path.

metzman updated this revision to Diff 60699.Jun 14 2016, 10:04 AM

Rename duplicate_stderr to maybe_duplicate_stderr().

kcc added a comment.Jun 14 2016, 11:53 AM

LGTM with nits.
You don't have commit access, do you?
Please ask Vitaly to land this for you

lib/Fuzzer/afl/afl_driver.cpp
74 ↗(On Diff #60699)

assert is not good here as we may compile this w/o assertions.
use

if (!...stream) {
    fprintf(stderr,...);
    abort();
}
lib/Fuzzer/test/afl-driver.test
11 ↗(On Diff #60699)

no need for this

metzman updated this revision to Diff 60729.Jun 14 2016, 12:58 PM

Replace assertion and fix test case.

  1. Replace assertion with print to stderr and abort().
  2. Remove call to unset() environmental variable in test case.
vitalybuka accepted this revision.Jun 14 2016, 1:45 PM
vitalybuka added a reviewer: vitalybuka.

Sure, I will this CL.
Also could you please mark addressed comments as "done" in future?

This revision is now accepted and ready to land.Jun 14 2016, 1:45 PM
This revision was automatically updated to reflect the committed changes.
This revision is now accepted and ready to land.Jun 14 2016, 3:16 PM

Please let me know if you need help with this.

This revision was automatically updated to reflect the committed changes.