Skip to content

tee: exercise short writes through splice fallback - #14979

Open
mattsu2020 wants to merge 3 commits into
uutils:mainfrom
mattsu2020:short-write.sh
Open

mattsu2020 wants to merge 3 commits into
uutils:mainfrom
mattsu2020:short-write.sh

Conversation

@mattsu2020

@mattsu2020 mattsu2020 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

The GNU short-write check bypasses injected write faults through tee's splice path. Include splice in the trace filter and force stdout to use the read/write fallback with an idempotent test adjustment.

Add an independent Rust test using append mode and a file-size limit to exercise a real short write without strace, verify the retry reports the error, and check that stdout receives all input.

Refs #14981

The independent reproduction passes with strace 6.13 and 7.2. Linux tee tests (36) pass without strace; shell syntax, spelling, and repeated preparation pass. The GNU 9.12 test itself was not run locally.

@xtqqczze

This comment was marked as outdated.

@xtqqczze

This comment was marked as outdated.

Comment thread src/uu/tee/src/tee.rs Outdated
@mattsu2020 mattsu2020 changed the title tee: use write_all for regular-file stdout tee: exercise short writes through splice fallback Sep 30, 2026
@oech3

This comment was marked as outdated.

Comment thread util/gnu-patches/tests_tee_short_write.patch Outdated
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tee/short-write is no longer failing!

Comment thread tests/by-util/test_tee.rs Outdated
use uutests::new_ucmd;

#[test]
fn test_tee_short_writes_after_splice_fallback() {

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.

This test was copy and pasted from GNU's test which is GPL3.

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.

I don't know any proper solution for this. Can we cause short-write without using strace (and contribute to GNU) under realistic situation?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was copy and pasted from GNU's test which is GPL3.

@oech3 That’s quite a strong accusation to make. I’d suggest being more careful with your wording.

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.

What is strong? This is not a sentense to some specific people.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattsu2020 Could you please make sure you’ve personally read and understood CONTRIBUTING.md, particularly the "AI policy" section?

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.

OK. It is much milder than my one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattsu2020 Could you please make sure you’ve personally read and understood CONTRIBUTING.md, particularly the "AI policy" section?

I hadn't gotten around to checking the comparisons in the GNU coreutils source code.
I'll make sure to do that from now on.

Comment thread tests/by-util/test_tee.rs Outdated
Comment thread tests/by-util/test_tee.rs Outdated
Comment thread util/build-gnu.sh Outdated
Comment thread util/build-gnu.sh Outdated
Comment thread util/build-gnu.sh Outdated
Co-authored-by: oech3 <79379754+oech3@users.noreply.github.com>
@mattsu2020
mattsu2020 marked this pull request as draft September 30, 2026 23:37
Comment thread util/build-gnu.sh
Comment thread util/build-gnu.sh
# strace only injects faults into traced calls. Include splice to force tee's
# stdout path to use read/write and exercise short-write retries. The
# replacement stops matching after the first edit, avoiding duplicate options.
sed -i 's/-e trace=write /-e trace=write,splice -e fault=splice /' \

@oech3 oech3 Oct 1, 2026 •

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.

Does it mean splice fails only for fd=1 if --trace-fds=1 is given?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.
With --trace-fds=1, the fault injection applies only to splice calls operating on fd 1.

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.

That is OK. But I'd like to add test case with failure of splice for fd=0 at different PR. Both uses write_all, but they exist on different place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll address it in a separate PR.

@mattsu2020
mattsu2020 marked this pull request as ready for review October 1, 2026 09:24

This branch has not been deployed

No deployments
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.

3 participants