Skip to content

tee: replace the pipe a failed output used - #15132

Merged
sylvestre merged 1 commit into
uutils:mainfrom
abendrothj:tee-replace-failed-pipe
Oct 7, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
abendrothj:tee-replace-failed-pipe

Conversation

@abendrothj

@abendrothj abendrothj commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

On Linux, tee copies its input to the outputs through two pipes. When splicing to one output failed part-way (EFBIG, ENOSPC), the bytes it didn't take stayed in the pipe. The other outputs would get them in front of their next chunk, and with the 2nd pipe left part-full tee panicked on its 2nd pipe should have enough spare assertion.

After a failed output, the old pipe is now closed and replaced with an empty one. A new pipe gets the larger size only if the 2nd pipe got it at startup, so the 2nd is never smaller than the 1st. The old pipe is closed first, so this also works at the open file limit. If no new pipe can be made, tee fails with the error. test_tee_failed_output_does_not_spill_into_others and test_tee_failed_output_at_open_file_limit fail on main and pass here.

Split out of #15086.

Closes #15119

Copilot AI balanced review requested due to automatic review settings October 6, 2026 07:28

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/uu/tee/src/tee.rs Resolved
Comment thread src/uu/tee/src/tee.rs Resolved
Comment thread src/uu/tee/src/tee.rs Resolved
Copilot AI balanced review requested due to automatic review settings October 6, 2026 08:10

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 08:18

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/uu/tee/src/tee.rs Resolved
Comment thread src/uu/tee/src/tee.rs Resolved
Copilot AI balanced review requested due to automatic review settings October 6, 2026 08:45

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 09:08

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/uu/tee/src/tee.rs Resolved
Copilot AI balanced review requested due to automatic review settings October 6, 2026 09:32
@abendrothj
abendrothj force-pushed the tee-replace-failed-pipe branch from fa83021 to 95228ac Compare October 6, 2026 09:32

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sylvestre

Copy link
Copy Markdown
Contributor

Seems that it makes coverage sad:


    running 1 test
    bin: "/home/runner/work/coreutils/coreutils/target/debug/coreutils"
    write(default): /tmp/.tmpDxGTOX/in
    run: /home/runner/work/coreutils/coreutils/target/debug/coreutils tee capped /dev/null capped2
    test test_tee::linux_only::test_tee_failed_output_does_not_spill_into_others ... FAILED

    failures:

    ---- test_tee::linux_only::test_tee_failed_output_does_not_spill_into_others stdout ----
    ---- test_tee::linux_only::test_tee_failed_output_does_not_spill_into_others stderr ----


    failures:
        test_tee::linux_only::test_tee_failed_output_does_not_spill_into_others

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 6075 filtered out; finished in 0.30s
    
  stderr ───

    thread 'main' (80690) panicked at tests/by-util/test_tee.rs:730:14:
    assertion failed: `(left == right)`

    Diff < left / right > :
     tee: capped: File too large
     tee: capped2: File too large
    <LLVM Profile Error: Failed to write file "/home/runner/work/coreutils/coreutils/coverage/traces/coverage-15187755631959443666_2.profraw": File too large
     

tee duplicates its input through two pipes on Linux. When splicing from
one of them to an output failed part-way, for example with ENOSPC or
EFBIG, the bytes the output did not take stayed in the pipe, and the
remaining outputs got them in front of their next chunk.

Replace the pipe with an empty one after a failed output. The old pipe
is closed first, so that this also works at the open file limit. A new
pipe gets the larger size only if the 2nd pipe got it at the start, so
that the 2nd is never smaller than the 1st. If no new pipe can be made,
tee fails with the error.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 23:23
@abendrothj
abendrothj force-pushed the tee-replace-failed-pipe branch from 95228ac to b2c51e5 Compare October 6, 2026 23:23

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@abendrothj

Copy link
Copy Markdown
Contributor Author

thanks, that's the coverage build writing its profile under the same size limit. both tests now check exit code 1 and use stderr_contains, like the dd/cp size-limit tests. with -Cinstrument-coverage on Linux they failed before and pass now; extra stderr lines no longer fail them, a panic still does.

Comment thread src/uu/tee/src/tee.rs Resolved
@oech3

This comment was marked as resolved.

@sylvestre
sylvestre merged commit 2c545f6 into uutils:main Oct 7, 2026
99 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tee: panics when an output fails part-way

4 participants