Skip to content

sort: propagate temporary file write errors - #14388

Open
tasodoufu wants to merge 1 commit into
uutils:mainfrom
tasodoufu:fix/sort-propagate-temp-write-errors
Open

sort: propagate temporary file write errors#14388
tasodoufu wants to merge 1 commit into
uutils:mainfrom
tasodoufu:fix/sort-propagate-temp-write-errors

Conversation

@tasodoufu

Copy link
Copy Markdown

Summary

Fixes #14377.

Reproduction

When external sort spills a chunk to a temporary file, a write failure (for example, ENOSPC/EFBIG) reached write_lines, whose write_all calls unconditionally used unwrap(). The process therefore panicked instead of reporting the I/O error and exiting non-zero.

Cause

The temporary-file chunk writer discarded the io::Result from both line and separator writes.

Fix

Propagate write errors from write_lines to the external-sort path with ?, preserving the existing error handling and cleanup flow. Added a regression unit test using a writer that returns StorageFull.

Validation

  • cargo fmt --check
  • cargo test -p uu_sort
  • cargo clippy -p uu_sort --all-targets -- -D warnings
  • git diff --check

The focused test and full uu_sort unit-test suite pass (29 tests).

Not verified

A real full/size-limited filesystem was not mounted in this environment; the regression test deterministically exercises the same failing Write path.

AI assistance was used to help inspect the issue and prepare this patch; the submitted change was reviewed and verified against the repository's contributing and AI-policy requirements.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/pid-pipe (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Note: The gnu test tests/tail/pipe-f is now being skipped but was previously passing.
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

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.

sort aborts instead of exiting non-zero when a temp-file write fails during external-sort spill

1 participant