fix(sort): explicitly clean up temp directory in TmpDirWrapper::Drop#11888
Merged
Conversation
The `TmpDirWrapper::Drop` only cleared handler state without attempting to delete the temporary directory. Cleanup relied entirely on the inner `TempDir::Drop`, which silently ignores errors via `let _ = remove_dir_all()`, potentially leaking `/tmp/uutils_sortXXXX` directories. Now `remove_tmp_dir` is called explicitly before `TempDir::Drop` runs, providing a safety net for cases where the silent cleanup would fail. Closes: uutils#11728
|
GNU testsuite comparison: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TmpDirWrapper::Dropnow explicitly callsremove_tmp_dir()before the innerTempDir::DroprunsDroponly cleared handler state, relying entirely onTempDir::Dropwhich silently ignores errors vialet _ = remove_dir_all()/tmp/uutils_sortXXXXdirectories to leak, eventually filling/tmpand triggering "disk quota exceeded" errorsRoot Cause
The cleanup chain was:
TmpDirWrapper::Drop→ clears handler state only (no directory cleanup)TempDir::Drop→ callsremove_dir_all()but silently swallows errors withlet _ =When
TempDir::Dropfailed (e.g., due to open file handles during error paths), the directory was permanently leaked with no retry or logging.Closes: #11728