Skip to content

Conversation

@martinkunkel2
Copy link
Contributor

@martinkunkel2 martinkunkel2 commented Dec 2, 2025

Use case is that two files are piped into comm, i.e. in bash

   comm <(cat file1) <(cat file2)

see also full example in #9537

Before the fix, comm reads from the pipes twice. Once in "fn comm" and
once in "fn are_files_identical". As such, part of the data is skipped
in comparison which leads to wrong output.

This is fixed by skipping the file comparison in case one of the files is not a regular file.

This fixes #9537

@martinkunkel2 martinkunkel2 force-pushed the comm_fix_anonymous_pipes branch from bd3c2e3 to 2ebd3da Compare December 2, 2025 22:17
@github-actions
Copy link

github-actions bot commented Dec 2, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@martinkunkel2 martinkunkel2 force-pushed the comm_fix_anonymous_pipes branch from 2ebd3da to 5c944e5 Compare December 3, 2025 18:55
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@martinkunkel2 martinkunkel2 force-pushed the comm_fix_anonymous_pipes branch from 93d9b01 to a9a638c Compare December 4, 2025 20:06
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

could you please add a test to make sure we don't regress? thanks

@martinkunkel2 martinkunkel2 force-pushed the comm_fix_anonymous_pipes branch from 3dd232a to f9720dd Compare January 7, 2026 19:06
@martinkunkel2
Copy link
Contributor Author

martinkunkel2 commented Jan 7, 2026

Tried to add a test.

On my machine (Linux, WSL2, devcontainer) the test fails if the fix is not applied:

---- test_comm::test_anonymous_pipes stdout ----
bin: "/workspaces/coreutils/target/debug/coreutils"
run: /workspaces/coreutils/target/debug/coreutils comm -13 /proc/197084/fd/33 /proc/197084/fd/35

thread 'test_comm::test_anonymous_pipes' (197138) panicked at tests/by-util/test_comm.rs:696:10:
Command was expected to succeed. code: 1
stdout = 
 stderr = comm: file 1 is not in sorted order
comm: file 2 is not in sorted order
comm: input is not in sorted order

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    test_comm::test_anonymous_pipes

and passes with the applied fix in comm.rs.

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 7, 2026

Merging this PR will improve performance by 7.93%

⚡ 1 improved benchmark
✅ 281 untouched benchmarks
⏩ 38 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory sort_ascii_utf8_locale 6.7 MB 6.2 MB +7.93%

Comparing martinkunkel2:comm_fix_anonymous_pipes (4adb9f4) with main (0b58260)

Open in CodSpeed

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.

@martinkunkel2 martinkunkel2 force-pushed the comm_fix_anonymous_pipes branch from f9720dd to dfc195d Compare January 7, 2026 20:56
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@martinkunkel2 martinkunkel2 force-pushed the comm_fix_anonymous_pipes branch from dfc195d to 519cb19 Compare January 7, 2026 21:27
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@martinkunkel2
Copy link
Contributor Author

@sylvestre : test added. please re-review.

Failure in CI (windows-latest) is most likely independent of my changes. Could you please retrigger the job to be sure?

Use case is that two files are piped into comm, i.e. in bash
   comm <(cat file1) <(cat file2)

Before the fix, comm reads from the pipes twice. Once in "fn comm" and
once in "fn are_files_identical". As such, part of the data is skipped
in comparison which leads to wrong output.

This is fixed by skipping the file comparison in case one of the files
is not a regular file.
@martinkunkel2 martinkunkel2 force-pushed the comm_fix_anonymous_pipes branch from 519cb19 to 4adb9f4 Compare January 17, 2026 09:21
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/tail/follow-name. tests/tail/follow-name is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@martinkunkel2
Copy link
Contributor Author

@sylvestre : resolved merged conflicts, ready to be reviewed.

@sylvestre sylvestre merged commit 75f45e8 into uutils:main Jan 17, 2026
158 checks passed
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.

comm: errors when using process substitution

2 participants