Skip to content

Conversation

@andreacorbellini
Copy link
Contributor

@andreacorbellini andreacorbellini commented Oct 30, 2025

If a read error happens after opening the file, that error is never reported and comm just quits without printing any error message. This commit fixes that.

This also removes the is_dir() check, preventing a potential race condition where the path could be swapped with a directory in between the is_dir() check and the open() call. On Unix, this correctly results in the "is a directory" error message to be printed (this is detected at read() time).

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 30, 2025

CodSpeed Performance Report

Merging this PR will degrade performance by 3.26%

Comparing andreacorbellini:comm-safer-is_dir (65cd809) with main (ca13e33)

Summary

❌ 1 regressed benchmark
✅ 281 untouched benchmarks
⏩ 38 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory dd_copy_partial 129.1 KB 133.5 KB -3.26%

Footnotes

  1. 38 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@andreacorbellini andreacorbellini changed the title comm: check if the input file is a directory after opening it comm: report all I/O errors Oct 31, 2025
@andreacorbellini
Copy link
Contributor Author

For Windows I decided to stick with the same behavior of Unix: report the error from the operating system. In the case of Windows, if the file is a directory, you get "permission denied". Not very user friendly, but I think this is the best approach, mostly because it's not racy.

If the maintainers don't like that, we can add a metadata check just for Windows (not on Unix), maybe something like: try to open the file, if it fails with a "permission denied", check if it's a directory, and based on that report the most appropriate error message. Let me know what you prefer and I will update the PR accordingly.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

I/O errors were being silently suppressed. This also removes an
unnecessary check to see if one of the inputs is a directory.
@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/pr/pr-tests was skipped on 'main' but is now failing.

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.

2 participants