Repository navigation
stop echoing captured output after any persistent write error - #18399
Conversation
When the terminal that launched the session goes away, echoing captured output to the saved stderr descriptor fails with EIO, which was logged on every write and retried forever. With a stderr log destination active, each logged error itself lands in the capture pipe, creating a feedback loop that spins at 100% CPU. Treat any non-transient write error like EPIPE/EBADF: disable the echo and log once. Addresses #18398.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
RStudio E2E - all platformsAll tests passed!
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
Code review findingsActionable items from an automated multi-agent review. The core fix checks out: the loop terminates (including the cross-stream stdout-fails-then-stderr-fails case, which bounds at two extra iterations), and console delivery is unaffected because Important
Suggestions
|
gtritchie
left a comment
There was a problem hiding this comment.
Feedback posted, mostly seems to be nice-to-have at most.
Summary
An rsession was found spinning at ~93% CPU for hours, flooding its log with
system error 5 (Input/output error)entries microseconds apart, all fromPosixOutputCapture.cpp:101. Full diagnosis in #18398; the short version:dup()'d copies of the original descriptors, so output still reaches the launching terminal.write()fails withEIO. OnlyEPIPE/EBADFset the "skip further writes" flag; every other errno was logged on every failed write, and retried forever.log-stderr=1set (as in the dev config), each logged error is written to fd 2 -- the redirected capture pipe -- so the capture thread reads its own error message, fails to echo it, and logs again: a self-sustaining loop at full CPU speed, with continuous log rotation churn on the side.log-stderr=1is the sole trigger: the same option both enables the echo writes (it is passed asforwardOutputToOriginalDescriptors) and installs the stderr log destination, so the two halves of the loop always arrive together. A stderr logger configured vialogging.confalone cannot reproduce this, because withoutlog-stderrthere are no echo writes to fail.Fix
Treat any non-transient write error (anything other than
EAGAIN/EINTR) the wayEPIPE/EBADFwere already treated: disable further echo writes and log the error once. The errno-specific message text is folded into a single generic description; the underlying errno is still reported bysystemError.Trade-off: a theoretically recoverable errno (say, transient
ENOSPCon a redirected file) now permanently disables the echo for the remainder of the session, same as a closed pipe always has. Given that the echo target is the launching terminal and the alternative is an unbounded logging loop, that seems like the right side to err on. Client-visible console output is unaffected -- it flows through the capture handlers, not the echo path.Verified the edited file compiles with the project's real compile flags (
-fsyntax-onlyviacompile_commands.json). Manual verification of the full loop requires killing the launching pty out from under a session with stderr logging enabled.Addresses #18398.