This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] Allow discarding output in ExecuteCommand in Fuchsia.
ClosedPublic

Authored by charco on Jan 16 2020, 5:33 PM.

Details

Summary

This commit modifies the way ExecuteCommand works in fuchsia by adding
special logic to handle /dev/null.

The FuzzerCommand interface does not have a way to "discard" the output,
so other parts of the code just set the output file to getDevNull().
The problem is that fuchsia does not have a named file that is
equivalent to /dev/null, so opening that file just fails.

This commit detects whether the specified output file is getDevNull,
and if that's the case, it will not copy the file descriptor for stdout
in the spawned process.

NOTE that modifying FuzzerCommand to add a "discardOutput" function
involves a significant refactor of all the other platforms, as they all
rely on the toString() method of FuzzerCommand.

This allows libfuzzer in fuchsia to run with fork=1, as the merge
process (FuzzerMerge.cpp) invoked ExecuteCommand with /dev/null as the
output.

Diff Detail

Event Timeline

charco created this revision.Jan 16 2020, 5:33 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 16 2020, 5:33 PM
Herald added subscribers: llvm-commits, Restricted Project. · View Herald Transcript
charco updated this revision to Diff 238672.Jan 16 2020, 5:41 PM

Ran clang-format

aarongreen accepted this revision.Jan 17 2020, 12:06 PM
This revision is now accepted and ready to land.Jan 17 2020, 12:06 PM

Thanks for the review, Aaron!

This revision was automatically updated to reflect the committed changes.
eep added a subscriber: eep.Feb 5 2020, 2:55 PM