Repository navigation
fix: exit 12 when the remote shell dies before the version exchange, as upstream - #8283
Merged
Merged
Conversation
upstream setup_protocol() writes and reads the protocol int through io.c safe_write()/safe_read(), which exit RERR_STREAMIO on any failure (io.c:401-405, io.c:356-358), and whine_about_eof() does the same on EOF. RERR_STARTCLIENT is only main.c:1981. oc mapped a version-write EPIPE to 5, so a remote shell that died first exited 5 or 12 depending on which side of the race the write landed. The handshake now tags a failed write or read with its step, and one classifier turns the tag into 12 with upstream's safe_write/safe_read or EOF line for the rsh, embedded-ssh and async-ssh transports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RERR_STARTCLIENT) whenever its version write hit EPIPE before its read saw EOF. That is what madeexit_code_12_stream_io::remote_shell_killed_by_signal_before_handshake_returns_stream_ioflaky (fix(batch): mirror upstream batch writing, replay and option checks #8250, musl nightly job 123007367229).setup_protocol()(compat.c:606-607) runs before buffered I/O starts, sowrite_int/read_intgo through io.csafe_write()/safe_read(). Both exitRERR_STREAMIOon any failure (io.c:401-405, io.c:356-358), andwhine_about_eof()does the same on EOF (io.c:299-303).RERR_STARTCLIENTis only main.c:1981, wherestart_client()returns -1 before any I/O.perform_handshake_with_maxnow tags a failed version write or read with its step (transfer::VersionExchangeError). The error keeps itsio::ErrorKind, andrerr_for_io_errorgrades the tag asRERR_STREAMIO, not the connection-classRERR_SOCKETIO.client::remote::version_exchange::version_exchange_failure, builds the error with upstream's line for each failure: the rsyserr[sender] safe_write failed to write 4 bytes to socket: Broken pipe (32), thesafe_readline, or the EOF whine. It still keeps a worse child exit code. The rsh driver, embedded-ssh and async-ssh all use it; the last two used to hard-code 5.Oracle evidence
I forced the write-first ordering with
strace -e inject=write:error=EPIPE:when=1against the same stub,sh -c 'exec 1>&-; read -r _':The upstream lines come from the 3.5.1 tarball build (
/home/ofer/up351/rsync-3.5.1/rsync, "rsync version 3.5.1"), the build CI'srun_interop.shmatches.Runs of the race stub
sh -c 'exec 0<&- 1>&-':Upstream itself takes both orderings, so the race belongs to the scenario, not to oc. That is why no e2e test pins the text of a racing stub. Each e2e arm is built so only one ordering is possible.
Before this change, oc exited 5 on the safe_write ordering.
Test plan
tests/exit_codes.rs:remote_shell_killed_by_signal_before_handshake_returns_stream_ionow uses a stub that closes its stdout and keeps reading stdin until the client lets go, then kills itself with SIGTERM. The client's write always lands and its read always sees EOF, so there is one ordering and no race. It asserts exit 12 and the EOF line.remote_shell_closing_stdout_before_handshake_prints_upstream_eof_whineis the strict EOF arm on push. Its stub closes stdout and drains stdin, so the write lands and the read sees EOF. It asserts exactly two stderr lines, byte-compared with the tarball 3.5.1 for the same stub, program name and trailer source location aside:connection unexpectedly closed (0 bytes received so far) [sender]and theerror in rsync protocol data stream (code 12) at ... [sender=<version>]trailer.RERR_STARTCLIENT-D warnings, the windows-gnu check (-p core -p transfer --tests), and targeted nextest.Known limits
[Receiver]in both the EOF line and the trailer ([Receiver=3.5.1]). oc prints[receiver](exit 12 either way). Task 268 adds that role, with its own strict pull EOF arm. This PR deliberately adds no pull e2e, so no test pins the wrong spelling.Conventional commit prefix
fix:Pre-merge checklist
cargo fmt --allrun locally.CHANGELOG.mdupdated (#8283to be replaced aftergh pr create).