cat: diagnose splice errors - #13812
Conversation
The splice() fast path swallowed every error as a silent read/write fallback, so a splice failure after some bytes were copied (e.g. an EIO injected by strace in tests/cat/splice.sh) produced no diagnostic. Once any data has been copied, treat a splice error as fatal and report it as "cat: <input>: …" on the read side or "cat: write error: …" on the write side; failures before the first byte still fall back to read/write. Write errors elsewhere now also omit the input file name. Fixes tests/cat/splice.sh (backported in util/fetch-gnu.sh). Signed-off-by: MuntasirSZN <muntasir.joypurhat@gmail.com>
Merging this PR will not alter performance
Comparing Footnotes
|
sylvestre
left a comment
There was a problem hiding this comment.
Please add a test to make sure we don't regress in the future
Signed-off-by: MuntasirSZN <muntasir.joypurhat@gmail.com>
|
Done @sylvestre |
Signed-off-by: MuntasirSZN <muntasir.joypurhat@gmail.com>
|
I don't agree with this approach. This should be shared at uucore for all utils. Also distioction for read/write is not splice specific. |
|
Why cannot we simply use |
Note that error distinction is disabled until next releas of GNU at backporting at https://github.com/uutils/coreutils/blob/main/util/fetch-gnu.sh . |
Signed-off-by: MuntasirSZN <muntasir.joypurhat@gmail.com>
| /// moved just falls back to read/write. Once data has been moved, any | ||
| /// splice error is reported, tagged with the direction that failed. | ||
| #[inline] | ||
| pub fn splice_unbounded_diagnose( |
There was a problem hiding this comment.
I meant we should improve existing code. Not introducing new fn. We probably should have several PRs for it instead of 1 PR e.g. https://github.com/uutils/coreutils/pull/12832/changes
There was a problem hiding this comment.
This means we need to wait for your pr + anything that I might create then this one.
There was a problem hiding this comment.
Dropped the new uucore function and specialized types — the loop now lives in cat with the first cycle split out, and write errors are built via .map_err_context(||
translate!("common-write-error")) (shared UIoError). CatError::Write is only a marker so cat_files doesn't prefix the input filename during multi-file aggregation. Once #12832 and
the read/write separation in uucore::pipes land, I'll switch cat to the improved shared helper and delete the local copy.
Hmm, but not for me? For me locally without pr it doesn't pass. |
Signed-off-by: MuntasirSZN <muntasir.joypurhat@gmail.com>
|
GNU testsuite comparison: |
|
I still don't understand this large diff just for appending a new message to existing error message. |
Function, it is (will move to uucore once your prs are done). Enum, no, because it is the idiomatic way as Errors should be in a large enum. Macro, well sylvestre asked for it. |
|
We should remove |
Isn't that a good thing? In uucore it can have its own error, though CatResult and CatError isn't created by me, so its the maintainers decision. |
|
If we want to share logic for error with file path and distinction, utility specific abstriction is large barrier for sharing code base in my opinion. |
xtqqczze
left a comment
There was a problem hiding this comment.
I don’t have any further comments regarding this PR.
Note
Needs #12832
The splice() fast path swallowed every error as a silent read/write
fallback, so a splice failure after some bytes were copied (e.g. an
EIO injected by strace in tests/cat/splice.sh) produced no diagnostic.
Once any data has been copied, treat a splice error as fatal and report
it as
cat: <input>: …on the read side orcat: write error: …on thewrite side; failures before the first byte still
fall back to read/write. Write errors elsewhere now also omit the input
file name.
Now tests/cat/splice.sh passes.
Signed-off-by: MuntasirSZN muntasir.joypurhat@gmail.com