Skip to content

comm: avoid deadlock when both inputs use stdin - #15249

Merged
sylvestre merged 1 commit into
uutils:mainfrom
ozenyunus35:fix/comm-dash-dash-stdin
Oct 11, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
ozenyunus35:fix/comm-dash-dash-stdin

Conversation

@ozenyunus35

Copy link
Copy Markdown
Contributor

Refs #14705

Summary

Fix comm - - hanging when both input operands refer to standard input.

Previously, each - operand acquired a separate lock on stdin. Since the lock is not reentrant, the second acquisition could block indefinitely.

The change keeps a shared stdin handle and acquires the lock only while reading each line.

Testing

  • Added a regression test for comm - -.
  • Confirmed the test times out before the fix and passes afterward.
  • All 45 comm tests passed.
  • cargo fmt --check passed.
  • Clippy passed without warnings.
  • Also checked - combined with file inputs and comm -z - -.

The test fixture was written independently without copying GNU source code or test fixtures.

Each "-" operand took its own lock on stdin, and the second lock blocked
forever, so `comm - -` hung. Keep the stdin handle and lock it for each
read instead, so both operands take their lines from the one shared
stdin buffer.
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/comm/dash-dash is no longer failing!

@oech3

oech3 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Edit & add "Fixes #14219" to 1st comment.

@sylvestre
sylvestre merged commit 64c2b64 into uutils:main Oct 11, 2026
97 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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.

3 participants