Skip to content
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

[infra] Fix dataflow engine compilation for a runtime speed up (#1632). #3219

Merged
merged 1 commit into from
Jan 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions infra/base-images/base-builder/compile_dataflow
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
#
################################################################################

export LIB_FUZZING_ENGINE="/usr/lib/DataFlow*.o"
echo -n "Compiling DataFlow to $LIB_FUZZING_ENGINE... "
mkdir -p $WORK/libfuzzer
pushd $WORK/libfuzzer > /dev/null

$CXX $CXXFLAGS $SANITIZER_FLAGS -std=c++11 -O2 -c \
$SRC/libfuzzer/dataflow/*.cpp
ar r $LIB_FUZZING_ENGINE $WORK/libfuzzer/*.o
$CXX $CXXFLAGS -fno-sanitize=all $SANITIZER_FLAGS -std=c++11 -O2 -c \
$SRC/libfuzzer/dataflow/DataFlow.cpp
$CXX $CXXFLAGS -fno-sanitize=all -fPIC -std=c++11 -O2 -c \
$SRC/libfuzzer/dataflow/DataFlowCallbacks.cpp

cp $WORK/libfuzzer/DataFlow*.o /usr/lib/

popd > /dev/null
rm -rf $WORK/libfuzzer
echo " done."
14 changes: 12 additions & 2 deletions infra/base-images/base-runner/bad_build_check
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ MIN_NUMBER_OF_RUNS=4
# Mercurial's bdiff_fuzzer has 116 PCs when built with ASan.
THRESHOLD_FOR_NUMBER_OF_EDGES=100

# A fuzz target is supposed to have at least two functions, such as
# LLVMFuzzerTestOneInput and an API that is being called from there.
THRESHOLD_FOR_NUMBER_OF_FUNCTIONS=2

# Threshold values for different sanitizers used by instrumentation checks.
ASAN_CALLS_THRESHOLD_FOR_ASAN_BUILD=1000
ASAN_CALLS_THRESHOLD_FOR_NON_ASAN_BUILD=0
Expand Down Expand Up @@ -95,8 +99,14 @@ function check_engine {
return 1
fi
elif [[ "$FUZZING_ENGINE" == dataflow ]]; then
# TODO(https://github.com/google/oss-fuzz/issues/1632): add check for
# binaries compiled with dataflow engine when the interface becomes stable.
$FUZZER &> $FUZZER_OUTPUT
local NUMBER_OF_FUNCTIONS=$(grep -Po "INFO:\s+\K[[:digit:]]+(?=\s+instrumented function.*)" $FUZZER_OUTPUT)
[[ -z "$NUMBER_OF_FUNCTIONS" ]] && NUMBER_OF_FUNCTIONS=0
if (( $NUMBER_OF_FUNCTIONS < $THRESHOLD_FOR_NUMBER_OF_FUNCTIONS )); then
echo "BAD BUILD: $FUZZER does not seem to be properly built in 'dataflow' config."
cat $FUZZER_OUTPUT
return 1
fi
return 0
fi

Expand Down