This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] Port executing system commands to OS X
AbandonedPublic

Authored by kubamracek on Dec 7 2015, 8:42 AM.

Details

Summary
  1. nproc doesn't exist on OS X, let's use sysctl instead.
  2. running system() on OS X takes a lock, so we can't do that on multiple threads.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 42073.Dec 7 2015, 8:42 AM
kubamracek retitled this revision from to [libFuzzer] Port executing system commands to OS X.
kubamracek updated this object.
kubamracek added reviewers: kcc, glider, samsonov.
kubamracek added subscribers: llvm-commits, zaks.anna.
kcc edited edge metadata.Dec 7 2015, 9:12 PM

Yay, thanks for doing this!

lib/Fuzzer/FuzzerIO.cpp
97

This code is gone, you should not need this chunk any more,

lib/Fuzzer/FuzzerUtil.cpp
65

I would like to minimize the number of ifdefs in the code.
Can we use sysctl on Linux? (If yes, just do it)

Also, if we need a simple if, something like this is better:
// in FuzzerInternal.h:
#ifdef APPLE
#define LIBFUZZER_APPLE 1
#else
#define LIBFUZZER_APPLE 0
#endif

// in the code:
command = LIBFUZZER_APPLE ? "foo_mac" : "foo_linux".

If we absolutely have to use ifdefs, make them lool like

#ifdef APPLE
int Foo() {
...
}
#else
int Foo() {
...
}

#endif

78

Assuming this code works on any Posix OS, let's just use your code and not have extra ifdefs

kubamracek abandoned this revision.Nov 28 2016, 4:44 PM