Skip to content

Commit 5a93114

Browse files
[infra] Indicate coverage run failure when libFuzzer reports an error (#13103)
Currently OOM's and timeouts for individual corpus entries during coverage measurement are silently ignored, as libFuzzer still exits with a zero returncode. This PR adds a grep for error messages during the coverage run. Additionally, add a small log file is created to indicate the fuzzer target for which the coverage measurement did not complete succesfully. --------- Signed-off-by: phi-go <dev@philipp-goerz.com> Co-authored-by: DavidKorczynski <david@adalogics.com>
1 parent 30567d0 commit 5a93114

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

infra/base-images/base-runner/coverage

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,15 @@ function run_fuzz_target {
9999

100100
export LLVM_PROFILE_FILE=$profraw_file
101101
timeout $TIMEOUT $OUT/$target $args &> $LOGS_DIR/$target.log
102-
if (( $? != 0 )); then
102+
cov_retcode=$?
103+
104+
target_error_log="$LOGS_DIR/${target}_error.log"
105+
grep -E "^==[0-9]+== ERROR: libFuzzer:" "$LOGS_DIR/$target.log" > "$target_error_log"
106+
grep_retcode=$?
107+
108+
if (( $cov_retcode != 0 || $grep_retcode == 0 )); then
103109
echo "Error occured while running $target:"
110+
echo "Cov returncode: $cov_retcode, grep returncode: $grep_retcode"
104111
cat $LOGS_DIR/$target.log
105112
fi
106113

@@ -126,6 +133,12 @@ function run_fuzz_target {
126133
llvm-cov export -summary-only -instr-profile=$profdata_file -object=$target \
127134
$shared_libraries $LLVM_COV_COMMON_ARGS > $FUZZER_STATS_DIR/$target.json
128135

136+
# If grep returned zero an error was matched.
137+
echo "Coverage error, creating log file: $FUZZER_STATS_DIR/${target}_error.log"
138+
if (( $cov_retcode != 0 || $grep_retcode == 0 )); then
139+
mv "$target_error_log" "$FUZZER_STATS_DIR/${target}_error.log";
140+
fi
141+
129142
# For introspector.
130143
llvm-cov show -instr-profile=$profdata_file -object=$target -line-coverage-gt=0 $shared_libraries $BRANCH_COV_ARGS $LLVM_COV_COMMON_ARGS > ${TEXTCOV_REPORT_DIR}/$target.covreport
131144
}

0 commit comments

Comments
 (0)