Skip to content

Report libFuzzer statistics in the libFuzzer tests check - #117142

Merged
alexey-milovidov merged 3 commits into
masterfrom
libfuzzer-report-stats
Sep 3, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
libfuzzer-report-stats

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

The check reports only OK/FAIL and a duration per fuzzer, and it uploads the fuzzer output only when the run failed. There is therefore no way to tell a target that is exploring new code from one that executes nothing: in this harness OK merely means "the process was still alive when the runner killed it at the timeout".

That is not hypothetical. tcp_protocol_fuzzer reports OK every night while never adding a single unit to its corpus, and execute_query_fuzzer and clickhouse_fuzzer spend 56-58 minutes of their one-hour budget replaying their own inputs before the first mutation - both facts had to be reverse engineered from corpus file timestamps in the artifact bucket, because none of it reaches the report.

runner.py now scrapes the libFuzzer progress lines into a stats.txt next to the existing status.txt, and records the corpus size before and after the run. The check renders them, so each fuzzer now reports, for example:

executed 15238 inputs, exec/s: 4, cov: 145140, ft: 512210, corp: 4470/23Mb, rss: 2100Mb
input directories: corpus/execute_query_fuzzer (4436 files), execute_query_fuzzer.in (10418 files)
replaying the initial corpus took 14854 of 15238 executed inputs (97%), leaving 384 mutations
34 new corpus units (4436 -> 4470)

Corpus minimization reports its reduction the same way, which until now was only visible by reading the job log.

The fuzzer output and stdout are also attached on success, not just on failure. To keep that affordable for long runs, a successful run's output is truncated to its first 1 MiB and last 7 MiB; output from a run that produced findings is left intact so that process_error still sees whole stack traces.

Related: #117140
Related: #117141

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Workflow [PR]
Sync PR [sync-upstream/pr/117142]

Version info

  • Merged into: 26.9.1.593 (included in 26.9 and later)

The check reports only `OK`/`FAIL` and a duration per fuzzer, and it uploads
the fuzzer output only when the run failed. There is therefore no way to tell
a target that is exploring new code from one that executes nothing: in this
harness `OK` merely means "the process was still alive when the runner killed
it at the timeout".

That is not hypothetical. `tcp_protocol_fuzzer` reports `OK` every night while
never adding a single unit to its corpus, and `execute_query_fuzzer` and
`clickhouse_fuzzer` spend 56-58 minutes of their one-hour budget replaying
their own inputs before the first mutation - both facts had to be reverse
engineered from corpus file timestamps in the artifact bucket, because none of
it reaches the report.

`runner.py` now scrapes the libFuzzer progress lines into a `stats.txt` next to
the existing `status.txt`, and records the corpus size before and after the
run. The check renders them, so each fuzzer now reports, for example:

    executed 15238 inputs, exec/s: 4, cov: 145140, ft: 512210, corp: 4470/23Mb, rss: 2100Mb
    input directories: corpus/execute_query_fuzzer (4436 files), execute_query_fuzzer.in (10418 files)
    replaying the initial corpus took 14854 of 15238 executed inputs (97%), leaving 384 mutations
    34 new corpus units (4436 -> 4470)

Corpus minimization reports its reduction the same way, which until now was
only visible by reading the job log.

The fuzzer output and stdout are also attached on success, not just on
failure. To keep that affordable for long runs, a successful run's output is
truncated to its first 1 MiB and last 7 MiB; output from a run that produced
findings is left intact so that `process_error` still sees whole stack traces.
@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [94bd796]

Summary: ✅


AI Review

Summary

This PR makes the libFuzzer tests report much more informative by surfacing parsed libFuzzer progress stats, attaching successful-run logs, truncating successful stderr logs, and adding tests/fuzz/runner.py to the job digest. The earlier cache-digest and minimization-log-size issues are fixed in the current head, but one new robustness regression remains in the report parser.

Findings

⚠️ Majors

  • ci/jobs/libfuzzer_test_check.py:267 The new stats files are optional diagnostics, but read_stats makes malformed JSON fatal. If runner.py opens stats.txt / stats_mini.txt and fails partway through json.dump (for example because the result volume is full), status.txt and the log artifacts still exist, yet json.load aborts process_results and turns the whole libFuzzer tests job into ERROR. Missing stats already degrade to {}; malformed stats should do the same and emit a warning instead of hiding the actual fuzzing result.
Final Verdict

Changes look good overall, but the new stats reader should stop treating malformed stats*.txt as a hard failure before this merges.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 30, 2026
Comment thread tests/fuzz/runner.py Resolved
Comment thread tests/fuzz/runner.py Resolved
…r.py` in the job digest

A successful corpus minimization run attached its full `out_mini.txt`, which can
hold an hour of libFuzzer progress lines; truncate it with the same policy as
the fuzzing output. Also add `tests/fuzz/runner.py` to the cache digest of the
`libFuzzer tests` and `libFuzzer corpus minimization` jobs, since the harness
logic now lives there and a runner-only change must not reuse a stale cache record.
if not stats_path.exists():
return {}
with open(stats_path, "r", encoding="utf-8") as file:
return json.load(file)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stats.txt / stats_mini.txt are auxiliary files produced inside the Docker runner, but read_stats now treats any malformed JSON as fatal. A concrete failure mode is write_stats opening the file and then failing mid-dump (for example ENOSPC while the job is already under artifact pressure): the status/output files are still present, yet json.load raises here and process_results aborts the whole libFuzzer tests check.

Since the missing-file case already degrades to {}, the malformed-file case needs the same treatment plus a warning in the report/log. Otherwise this reporting-only feature adds a new way for a finished fuzzing run to surface as job ERROR instead of showing the existing status and logs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Sep 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 3, 2026
Merged via the queue into master with commit a9c2890 Sep 3, 2026
175 checks passed
@alexey-milovidov
alexey-milovidov deleted the libfuzzer-report-stats branch September 3, 2026 11:55
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants