[PATCH] D72894: [libFuzzer] Allow discarding output in ExecuteCommand in Fuchsia.

Marco Vanotti via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 17:37:53 PST 2020


charco created this revision.
charco added reviewers: aarongreen, phosek.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72894

Files:
  compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72894.238671.patch
Type: text/x-patch
Size: 3956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200117/ea105060/attachment.bin>


More information about the llvm-commits mailing list