Repository navigation
Conversation
… verdict run-fuzzer.sh points every sanitizer runtime at *SAN_OPTIONS=log_path, so a reporting process writes its own sanitizer.log.<pid> and an EXIT trap merges them all into stderr.log/server.log. A report that kills the CLIENT leaves the server alive, so status.tsv is "0 0 134" and run_fuzz_job lands in the catch-all branch: it reported "Client failure (see logs)" plus a fuzzer.log tail and never named the finding. fuzzer.log holds no sanitizer text at all, so that paste was empty of it, and the parser that can name the report was gated behind `status != Result.Status.ERROR`, i.e. skipped on exactly that branch. The CIDB row's test_name stayed empty, which makes such a run unsearchable and read as benign. That is not hypothetical: AST fuzzer (amd_msan) on PR ClickHouse#111194 (c35d59b) uploaded a 5422-byte sanitizer.log.914 holding a MemorySanitizer use-of-uninitialized-value whose origin chain reads "created by a heap deallocation" (a use-after-free, fixed separately by ClickHouse#111725), and the job reported only "Client failure". CIDB has 22 such rows on sanitizer builds over 60 days (arm_asan_ubsan 11, amd_msan 6, amd_tsan 5). Parse every sanitizer.log.* once, before the exit-code logic, and let the result force a red verdict in every branch and become a named sub-result. Details worth recording: - Every file is parsed, never just the newest or the first, and the merged log is not used for selection: distinct processes report independently and the runner concatenates them in glob order, so a benign or fatal-OOM record must not shadow or outrank a real finding. - Benign-ness is decided on the raw diagnostic FuzzerLogParser selected, not on the file (a recoverable "failed to allocate" warning does not abort, so one file can hold a benign record followed by a real one) and not on the normalized name (which drops "failed to allocate", so a name test would promote every benign report). - The report path is the parser's only input, so no pattern can reach the real server.log and name the normal shutdown's "Received signal 15". - The veto reaches the benign (0, 137, 143) exit codes too: *SAN_OPTIONS is inherited by the server and by ignored client probes, while fuzzer_exit_code is only `wait "$fuzzer_pid"`. - ERROR is kept explicitly where it was already decided, because Result.create_from derives the status from sub-results and a FAIL sub-result would downgrade it; the catch-all note is keyed on that branch rather than on the status so BuzzHouse's own diagnostic survives. - Stale per-run state is removed before the container starts. praktika reuses worktrees and ci/tmp is gitignored, and status.tsv is written only at the very end under `set -e`, so a stale success tuple would classify the next run. The regression tests drive the real run_fuzz_job against a seeded workspace; 22 of them fail on master. Each fix clause was mutation-tested: reverting it alone makes a specific named test fail (12/12).
…benign one Two gaps in the sanitizer-report classification added by the previous commit, both of which could still lose or invent a fuzzer signal. The per-report pass swallowed every parser exception and dropped every report that yielded no usable diagnostic. Measured, two distinct inputs reach those paths: a missing `rg` or `head` on PATH surfaces as a non-zero exit code and raises, while a report that cannot be READ returns `Unknown error` without raising. Either one left `sanitizer_findings` empty, so a run whose fuzzer exited 0, 137 or 143 stayed OK with an unexamined report on disk - the very hidden-report outcome this classification exists to prevent, recreated by its own error handling. An unreadable report is a plausible state rather than a synthetic one: the container runs as root and the reports are chown'd afterwards. Such reports are now collected and reported as one named `Sanitizer report parse failure` sub-result, which forces the run failed (so the logs and the report are uploaded), promotes an OK verdict to FAIL, and vetoes the sanitized-build OOM leniency for the same reason a real finding does. The merged-log parse can raise for the same reasons and is now caught too, because forcing the run failed made that parse reachable on a branch where it previously never ran. `ci/jobs/stress_job.py` already fails closed the same way. The merged-log parse selects whichever sanitizer record the runner concatenated first, and a fatal out-of-memory record is a legitimate first. Its result was appended without the benign test the per-report pass applies, so a run holding both a fatal allocator record and a real finding emitted a FAIL sub-result - hence a CIDB `test_name` row - for the benign one. The name-based dedupe could not remove it because a benign record normalizes to the bare tool name. The same predicate now gates that row, scoped to sanitizer records: the shared pattern also matches the watchdog's "terminated by signal 9", which no sanitizer report holds and which the per-report pass therefore cannot name, so that row must survive. Comments and docstrings spell function names without application parentheses, per `.claude/CLAUDE.md`.
The non-sanitized branch of the classification reads the host's kernel ring buffer, which is not an input to these tests: on a host that has seen an OOM kill the real dmesg flips the verdict to ERROR and suppresses the merged-log parse the signal-9 test exists to exercise. Seed an empty dmesg.log from the fixture instead, leave the grep over it real so the branch logic stays under test, and assert both shell-outs happened. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`FuzzerLogParser.parse_failure` runs `rg ... | head -n10` without pipefail, and `Shell.get_output` only checks the pipeline's final exit status, so with `rg` absent the pipeline still succeeds with empty output and the parser returns `Unknown error` without raising. A readable, real sanitizer report then looked indistinguishable from one holding no recognizable diagnostic, so it was recorded neither as a finding nor as a parse failure and a run whose fuzzer exited 0, 137 or 143 stayed green with the report on disk. Classify an unrecognized result as a parse failure when a tool the parser shells out to is missing, naming the tool so the resulting row is diagnosable. A readable report holding no recognizable diagnostic is still not a finding. The three cases covering the fail-closed path were guarded by a `skipif(os.geteuid() == 0)` because they used `chmod 000`, and the `CI Tests` job runs as root, where permissions are not enforced, so that behavior shipped with no coverage on the only job that runs the file. Drive the production readability predicate instead of the permission bits and drop both markers: the file now reports 41 passed with 0 skipped as root as well as unprivileged.
Internal second-model review (4 rounds, 0 blockers outstanding) - click to expandBefore opening this I ran my own cold code review plus an independent second-model ❌ Blockers found and fixed during review
|
Pre-PR validation gate
Verification: 41/41 new tests pass, 31 of them fail on |
|
cc @leshikus - could you review this? An |
|
Workflow [PR], commit [b9fdafc] Summary: ✅ AI ReviewSummaryThis PR fixes Missing context / blind spots
Final Verdict✅ No new findings. |
|
@groeneai this was the real CI failure: |
|
Agreed, and that is the report this PR is about: it is the The C++ bug in it is already fixed. This PR does not touch that bug. It fixes why the report had to be pasted by hand. When the report kills the client the server is untouched, The same opaque verdict shape is on 15 sanitizer @PedroTadim your call on the harness change: if you would rather not have it, leaving this closed is fine by me. If you want it, reopen this PR, or say so and I will open a fresh one with the same change. I will not reopen it myself. |
Related: #111725
Related: #111934
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
An
AST fuzzer (*)run on a sanitizer build can be killed by a sanitizer report andstill be reported as an opaque
Client failure (see logs)with the finding nevernamed, so the CIDB row carries an empty
test_nameand the failure is unsearchable.ci/jobs/scripts/fuzzer/run-fuzzer.sharms every runtime with*SAN_OPTIONS=log_path=/workspace/sanitizer.log, so each reporting process writes itsown
sanitizer.log.<pid>, and an EXIT trap merges them all intostderr.logandserver.log. When the report kills the CLIENT the server is untouched, sostatus.tsvis0 0 134andrun_fuzz_joblands in the catch-allelse: it appendsClient failure (see logs)plus afuzzer.logtail. Two things then go wrong:fuzzer.logcontains no sanitizer text at all, so that paste holds none of it; and thenaming code is gated behind
if is_failed and status != Result.Status.ERROR, which isfalse on exactly this branch, so
FuzzerLogParsernever runs even though itsSANITIZER_ERROR_PATTERNmatches the report sitting instderr.log.Concretely,
AST fuzzer (amd_msan)on #111194(report,
sha
c35d59bfd914045a9d79d0cb692e96695b8215ad) uploaded a 5422-bytesanitizer.log.914holding("created by a heap deallocation" is MSan's wording for a use-after-free; that bug
itself is
ASTExecuteAsQuery's raw non-owning members, fixed separately by #111725).The job reported only
Client failure. Over the last 60 days CIDB has 22 suchClient failurerows on sanitizer builds -arm_asan_ubsan11,amd_msan6,amd_tsan5 - each of which may have hidden a report the same way.The fix parses every
sanitizer.log.*once, before the exit-code logic, and lets theresult force a red verdict in every branch and become a named sub-result. The details
that decide whether it is correct:
not used for selection: distinct processes report independently and the runner
concatenates them in glob order, so a benign or fatal-OOM record must not shadow or
outrank a real finding.
and not off the name. Not the file, because the recoverable warning
(
WARNING: MemorySanitizer failed to allocate 0x... bytes, no colon after the toolname) does not abort the process, so the runtime keeps appending and one file can hold
a benign record followed by a real one. Not the name, because the parser normalizes it
to
MemorySanitizer (STID: ...), droppingfailed to allocate, so a name test wouldpromote every benign report to a finding.
server.logand name the normal shutdown'sReceived signal 15.(0, 137, 143)exit codes.*SAN_OPTIONSis aplain
exportinherited by the server and by the ignored client probes, whilefuzzer_exit_codeis onlywait "$fuzzer_pid", so a runtime can report while thefuzzer exits 0 or 143.
ERRORalready decided upstream is kept explicitly, becauseResult.create_fromderives the status from sub-results when given none and aFAILsub-result would downgrade it; and the catch-all note is keyed on that branch rather
than on the status, so BuzzHouse's own
Found disallowed error codediagnosticsurvives.
worktrees and
ci/tmpis gitignored, andstatus.tsvis written only at the very endunder
set -e, so a stale success tuple from the previous run would classify this one.may itself be the finding, so it forces the same red verdict, vetoes the same OOM
leniency, and gets its own named
Sanitizer report parse failuresub-result with thereport attached. Three inputs reach that path and none is synthetic: the parser raises when
headis missing fromPATH, because the pipeline's exit status ishead's; a report thatcannot be READ parses to
Unknown errorwithout raising (the container runs as root and thereports are chown'd afterwards); and
rgalone missing parses toUnknown errortoo,because it is piped into
head, which exits 0 for the whole pipeline. The missing tool isnamed in the sub-result, so that row stays diagnosable. A report that is READABLE but holds no recognizable diagnostic is still not
a finding, which is what keeps this narrow. The merged-log parse below is wrapped the
same way, because forcing the run failed makes that parse reachable on a branch where it
previously never ran.
stderr.logand selects whichever record came first, so it can select a benign allocatorrecord; appending that produced a
FAILsub-result - hence a CIDBtest_namerow - forsomething the per-report pass had already classified as benign, and the name-based dedupe
could not remove it because a benign record normalizes to the bare tool name. The same
benign predicate now gates that row, scoped to sanitizer records: the shared pattern also
matches the watchdog's
Child process was terminated by signal 9, which nosanitizer.log.*holds and which nothing else names, so that row must survive.A benign allocation report on its own still gets today's lenient verdict.
Blast radius, since this can now redden a branch that used to pass: over three days of
master runs, 21 of 219 currently-green sanitizer fuzzer jobs already write a
sanitizer.log.*-ast_fuzzer_arm_asan_ubsan7 of 18,buzzhouse_arm_asan_ubsan14 of18, and none at all on
amd_msanoramd_tsan. In every one of those 21 the report isthe benign
ASan doesn't fully support makecontext/swapcontextwarning, which carries nocolon after the tool name and so matches neither parser start pattern: running
_sanitizer_findingsover that verbatim text yields no findings, as a single record anddoubled. None of those jobs turns red. Two adjacent classes were checked the same way and
also yield nothing: the symbolizer warnings and
__asan_handle_no_return, for the samemissing-colon reason, and
writable-executable page usage, which is gated ondetect_write_exec(default off, never set here).LeakSanitizercannot contributeeither, because
safeExitruns the leak check itself on ASan builds and three realarm_asan_ubsanserver.logartifacts contain no leak report.The recoverable-allocation half of the benign pattern is keyed on the wording compiler-rt
actually emits:
Report("WARNING: <Tool>Sanitizer failed to allocate 0x%zx bytes")isreached only when
AllocatorMayReturnNull, and ClickHouse always setsallocator_may_return_null=1, so the fatalexceeds maximum supported sizeform(
ReportAllocationSizeTooBig) is unreachable in these builds and the filter cannot miss arecoverable case.
ci/tests/test_ast_fuzzer_client_failure_sanitizer.pydrives the realrun_fuzz_jobagainst a seeded workspace (only the container run, the docker image, the ownership
repair, the core collection and the host
dmesgread are stubbed). 31 of its 41 assertions fail on master andall pass here; the 10 that pass on master encode existing behavior, which the change must
not alter. Each fix clause was mutation-tested - reverting it alone makes a specific
named test fail, 9 clauses, 9 detected.
The cleanup helper is deliberately byte-compatible with the one in #111934 (the
_clean_stale_run_stateand_preseeded_state_is_inputbodies are AST-identical modulodocstrings, and this PR's
_STALE_RUN_STATEis a strict subset of that PR's - it adds twomarker files of its own), so whichever lands first the other collapses the duplicate with
no semantic change. #109590 conflicts in a single line - both branches add
an import to the same block - and I ran the combination rather than assuming it: with that
resolved, both PRs' test files against the merged tree give 59 passing (41 + 18), and the
wider fuzzer/parser suites there give 71 passing. #111934
overlaps textually in 11 hunks of
ast_fuzzer_job.py- regions both PRs restructure -so whoever lands second resolves them; the two test files do not collide.