Skip to content

fix(daemon): clear the master red - rustdoc link, racing converter cause, and a pre-mangled log operand - #7639

Merged
oferchen merged 3 commits into
masterfrom
fix/daemon-log-escaping-vector
Sep 3, 2026
Merged

oferchen merged 3 commits into
masterfrom
fix/daemon-log-escaping-vector

Conversation

@oferchen

@oferchen oferchen commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Clears the three failures that have been red on master since #7627, and that
every open PR inherits. Three independent commits; each is separately
mutation-proven and none depends on the others.

1. rustdoc links (informational) — two unresolved links

Both errors were reported at crates/fast_io/src/io_uring/mod.rs:117, the ///
comment on pub mod send_zc;. Two things combine, and neither is visible alone:

  • ZeroCopySender is #[cfg(feature = "iouring-send-zc")] at both the struct
    and the re-export, so in a default build no path can resolve to it.
  • rustdoc concatenates a pub mod /// comment with that module's own //!
    block and resolves the result in the outer module's scope — which is why
    the errors point at mod.rs, not at the //! lines in send_zc.rs that
    actually contain them.

An --all-features doc build cannot see either half, which is how this reached
master. Both links become plain code spans, and the note at the site says why,
so the next reader does not "fix" them back into links.

2. name_converter — a first-cause assertion that races

a_dead_converter_fails_instead_of_answering_unknown pinned UnexpectedEof as
the recorded cause; CI measured BrokenPipe on all three nextest retries. Both
arms are legitimate: the child is exit 0, so if it has already exited when the
first lookup runs, the request write fails with EPIPE; if not, the write
lands and the answer read hits EOF.

What the test exists for is that the death is recorded and replayed, which is
orthogonal to which errno won. It now captures whichever cause the first failure
recorded and asserts the later lookup reports that, plus a bound that the
cause came from the pipe at all (UnexpectedEof | BrokenPipe) — without which
"sticky" would be satisfiable by an unrelated failure.

3. daemon_log_file_escaping — and a real divergence behind it

The test failed at its own non-vacuity guard, not at an assertion. #7633
stopped writing the client argument vector to the daemon log — correctly,
upstream never writes it at all — and that vector was this test's only subject.

Re-pointing it at a vector oc does log measured a live divergence. Upstream
escapes in the sink: logit() is the only writer of logfile_fp and hands
every line to filtered_fwrite(...) (log.c:126-132), so no call site
pre-cleans its operands, and clientserver.c:787 passes the module name
straight through. oc ports filtered_fwrite faithfully — but seven daemon log
builders wrapped the module name in sanitize_module_identifier first, which
replaces control characters with ?.

Measured on a module named A<ESC>B requested over a raw @RSYNCD handshake,
master writes both renderings into the same log file:

rsync allowed access on module A?B from localhost (127.0.0.1)
module 'A\#033B' from localhost (127.0.0.1): 0 client args

The second line is already correct — client_args_log_line does not sanitise,
so the sink escapes reversibly. The first is lossy: ? cannot be undone, and a
reader cannot tell an escaped byte from a literal question mark.

The sanitiser call is removed from all seven builders and deliberately kept
on the wire @ERROR reply path, a different sink with no escaping layer of its
own. One doc comment that claimed the name was "sanitised to strip control
chars" — true when written, false after this change — is corrected in the same
commit.

Not covered, and said so in the test header: an unresolvable module name.
Upstream logs those too (clientserver.c:1568), but oc opens a log sink only
per resolved module, so nothing before module resolution reaches a log file at
all. That is a real separate gap, recorded rather than papered over.

Verification

  • rustdoc: RUSTDOCFLAGS="-D warnings" cargo doc -p fast_io --no-deps clean
    on a default build (the configuration the gate builds).
  • name_converter: 19/19.
  • escaping: RED/GREEN proven by restoring the sanitiser calls — the test
    fails on the mangled-form assertion and prints both disagreeing lines.
  • daemon 1800/1800; daemon + log-file sweep across the workspace 82/82.
  • cargo fmt --all -- --check clean.

…le doc

`rustdoc links (informational)` has been red on master, reporting exactly two
errors, both at crates/fast_io/src/io_uring/mod.rs:117 - the `///` comment on
`pub mod send_zc;`:

  error: unresolved link to `ZeroCopySender`
  error: unresolved link to `ZeroCopySender::send_zc`

Two things combine to produce them, and neither is visible on its own.

`ZeroCopySender` is `#[cfg(feature = "iouring-send-zc")]` at BOTH the struct
(send_zc.rs:320) and the re-export (mod.rs:166), so in a DEFAULT build the type
does not exist and no path can resolve to it. Separately, `pub mod send_zc;`
carries a `///` comment, and rustdoc concatenates that with the module's own
`//!` block and resolves the result in the OUTER module's scope - which is why
the errors are reported against mod.rs:117 rather than against the `//!` lines
in send_zc.rs that actually contain them. crates/logging-sink/src/escape.rs
documents this same concatenation trap in its own header.

Both links become plain code spans. The prose already said the type is exposed
"when the `iouring-send-zc` cargo feature is enabled", so nothing is lost: a
link that cannot resolve in the configuration the doc gate actually builds is
not carrying the reader anywhere.

An `--all-features` doc build cannot see either half of this, which is how the
broken link reached master in the first place - the note now says so at the
site, so the next reader does not "fix" it back into a link.

Verified: `RUSTDOCFLAGS="-D warnings" cargo doc -p fast_io --no-deps` on a
default build is clean. The red baseline is CI's own two errors at this exact
file and line.
`a_dead_converter_fails_instead_of_answering_unknown` is the first of the two
tests that turned master red: it appeared at ed5a38b (#7627, an unrelated
sender diff), one commit after the run at 7a82dea that was green, and it
failed on all three nextest retries with

  assertion `left == right` failed: the recorded cause must be reported, not a
  fresh one: name converter: writing the request: Broken pipe (os error 32)
    left: BrokenPipe
   right: UnexpectedEof

The assertion pinned `UnexpectedEof` as the recorded cause. Which cause gets
recorded is a RACE, and both arms are legitimate: the child is `exit 0`, so if
it has already exited and closed the pipe when the first lookup runs, the
request WRITE fails with EPIPE and BrokenPipe becomes the sticky cause; if it
has not yet exited, the write lands and the answer READ hits EOF, recording
UnexpectedEof. Neither outcome is a defect - the host just decides which one
wins.

What the test exists for is the property one line below it in its own comment:
that the death is RECORDED and REPLAYED rather than the stream being spoken to
again. That property is orthogonal to which errno won the race, so the test now
captures whichever cause the first failure recorded and asserts the later
lookup reports THAT, plus a bound that the cause came from the pipe at all
(`UnexpectedEof | BrokenPipe`) rather than some unrelated error.

This deliberately keeps two assertions rather than deleting the errno check:
without the pipe-cause bound, a converter that failed for a completely
different reason would satisfy "sticky" trivially.

daemon --lib name_converter_tests: 16/16.
`daemon_log_file_escaping` is the second of the two tests that turned master
red. It failed at its own non-vacuity guard, not at an assertion: PR #7633
stopped writing the client's argument vector to the daemon log - correctly,
since upstream never writes it at all - and that vector was the test's only
subject. With nothing peer-supplied left in the log, every later assertion
would have passed vacuously, and the guard said so.

Re-pointing the test at a vector oc does log measured a real divergence.

Upstream escapes in the SINK. `logit()` is the only writer of `logfile_fp` and
hands every line to `filtered_fwrite(logfile_fp, buf, len, 0, 1, trailing)`
(log.c:126-132), so no call site needs to pre-clean its operands and none of
upstream's do: `clientserver.c:787` passes the module name straight into
`rprintf(FLOG, "rsync %s %s from %s@%s (%s)\n", ...)`. oc ports that
`filtered_fwrite` faithfully in `crates/logging-sink/src/escape.rs`.

But seven of oc's daemon log builders wrapped the module name in
`sanitize_module_identifier` first, which replaces every control character with
`?`. Measured on a module named `A<ESC>B`, requested over a raw @rsyncd
handshake, master writes BOTH renderings into the SAME log file:

  rsync allowed access on module A?B from localhost (127.0.0.1)
  module 'A\#033B' from localhost (127.0.0.1): 0 client args

The second line is already correct - `client_args_log_line` does not sanitise,
so the sink escapes reversibly. The first is lossy: `?` cannot be undone, and a
reader cannot tell an escaped byte from a literal question mark. Two builders
naming the same peer string in the same file disagreed about what it says.

The sanitiser call is removed from all seven builders. It is deliberately KEPT
on the wire `@ERROR` reply path, which is a different sink with no escaping
layer of its own; that is a separate decision and is not touched here.

The doc on `log_module_refused_option` claimed the name was "sanitised to strip
control chars" - true when written, false after this change - so it now says the
sink escapes it. Leaving it would have been exactly the drift this repo keeps
getting bitten by.

The test moves onto the module name as its vector and asserts three things: the
escaped form is present, the mangled form is absent, and no raw ESC byte reached
the file. The already-correct client-args line is the in-run control that proves
the sink works and the fixture is live, alongside a plain-named control module.
Its header records what is NOT covered: an unresolvable module name, which
upstream also logs (clientserver.c:1568) but oc cannot, because it opens a log
sink only per resolved module. That is a real separate gap, filed rather than
faked.

RED/GREEN proven by restoring the sanitiser calls: the test fails on the
mangled-form assertion, printing both disagreeing lines.

daemon 1800/1800; daemon + log-file sweep 82/82; fmt clean.
@github-actions github-actions Bot added the bug Something isn't working label Sep 3, 2026
@oferchen
oferchen merged commit da63603 into master Sep 3, 2026
77 checks passed
@oferchen
oferchen deleted the fix/daemon-log-escaping-vector branch September 3, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant