Skip to content

Fix: tail fails under pseudo with "couldn't allocate absolute path"#9305

Open
naoNao89 wants to merge 9 commits into
uutils:mainfrom
naoNao89:fix/issue-9292-tail-pseudo-canonicalize
Open

Fix: tail fails under pseudo with "couldn't allocate absolute path"#9305
naoNao89 wants to merge 9 commits into
uutils:mainfrom
naoNao89:fix/issue-9292-tail-pseudo-canonicalize

Conversation

@naoNao89
Copy link
Copy Markdown
Contributor

tail calls .canonicalize() on stdin pipes → triggers realpath() → pseudo fails with "couldn't allocate absolute path"

Fix: Check file type first. Skip canonicalization for pipes, only canonicalize regular files.

Fixes #9292

Verified: Tested with pseudo in Ubuntu container

podman run --rm -v $(pwd):/src:Z -w /src ubuntu:24.04 /bin/bash -c '
  apt update -qq && apt install -y -qq curl pseudo build-essential > /dev/null &&
  curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable &&
  . $HOME/.cargo/env &&
  cargo build --release -p uu_tail &&
  echo "/usr/bin/arch
/bin/busybox.nosuid 50" > /tmp/test-data.txt &&
  echo "=== Test WITHOUT pseudo ===" &&
  grep "50\$" /tmp/test-data.txt | ./target/release/tail -n 1 &&
  echo "=== Test WITH pseudo (issue #9292) ===" &&
  mkdir -p /tmp/pseudo && export PSEUDO_PREFIX=/tmp/pseudo &&
  pseudo sh -c "grep \"50\\\$\" /tmp/test-data.txt | ./target/release/tail -n 1" &&
  echo "✓ Fix verified: No '\''couldn'\''t allocate absolute path'\'' errors!"
'
=== Test WITHOUT pseudo ===
/bin/busybox.nosuid 50
✓ Pass

=== Test WITH pseudo (issue #9292) ===
/bin/busybox.nosuid 50
✓ Fix verified: No 'couldn't allocate absolute path' errors!

@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch 3 times, most recently from 2dda7a0 to 486df67 Compare November 16, 2025 14:42
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Nov 16, 2025

Merging this PR will not alter performance

✅ 319 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing naoNao89:fix/issue-9292-tail-pseudo-canonicalize (d904e16) with main (21fda8c)

Open in CodSpeed

Footnotes

  1. 46 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
Copy Markdown

GNU testsuite comparison:

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

Comment thread src/uu/tail/src/tail.rs Outdated
// On non-macOS systems, use is_stdin_directory() which works correctly
#[cfg(not(target_os = "macos"))]
{
if uucore::fs::is_stdin_directory(&stdin()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we simply fix the uucore function?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naoNao89 ping, have you seen this comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sr @@

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "sr"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naoNao89 are you an AI?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We clarified offline that "sr" means "sorry", and "@@" is a dizzy face smiley meaning overwhelmed / confused.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -> icon 😵 or 😵‍💫

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I were an AI, i would write comments in an expert tone, akin to a research paper or technical doc :v

@Ecordonnier Ecordonnier self-assigned this Feb 7, 2026
@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch from a875910 to 6fb203c Compare February 19, 2026 09:06
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/date/date-locale-hour is no longer failing!
Congrats! The gnu test tests/misc/io-errors is no longer failing!
Note: The gnu test tests/expand/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.

@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch from 6fb203c to 72737e7 Compare February 19, 2026 09:33
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/date/date-locale-hour is no longer failing!
Congrats! The gnu test tests/misc/io-errors is no longer failing!

@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch from 72737e7 to 98c7793 Compare February 19, 2026 11:23
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/cut/bounded-memory. tests/cut/bounded-memory is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/date/date-locale-hour. tests/date/date-locale-hour is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tail/symlink (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.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

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

@Ecordonnier
Copy link
Copy Markdown
Collaborator

Can you please check the CI issue?

@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch from bb9ced1 to f54dcc6 Compare May 25, 2026 06:08
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 25, 2026

GNU testsuite comparison:

GNU test failed: tests/tail/follow-stdin. tests/tail/follow-stdin is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/pipe-f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Congrats! The gnu test tests/printf/printf-surprise is now passing!

naoNao89 added 5 commits May 25, 2026 17:45
Avoid canonicalizing stdin when it's a pipe to prevent realpath()
errors under pseudo (Yocto/OpenEmbedded).

Changes:
1. In Input::resolve() (paths.rs): Check file type before canonicalizing.
   Only canonicalize regular files, skip pipes/fifos/dirs.

2. In tail_stdin() (tail.rs): Add early directory check for stdin.
   On non-macOS systems, detect directory stdin before path resolution
   to provide correct error message matching test expectations.

This fixes the issue where tail commands like 'grep pattern file | tail'
fail under pseudo with 'couldn't allocate absolute path' errors.

Fixes uutils#9292
The macOS-specific workaround in tail_stdin() was unnecessary because
fstat() on stdin's file descriptor correctly detects directories on
all Unix platforms, including macOS. The real macOS issue was with
canonicalize() on /dev/stdin paths, not with fstat().

Remove the duplicate platform-specific blocks and use a single call
to uucore::fs::is_stdin_directory() which works on all platforms.

Also consolidate the macOS-specific test into the cross-platform
test_stdin_redirect_dir test, producing the correct error message
on all platforms.

See: rust-lang/rust#95239
@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch from ba8ec45 to fc8d77d Compare May 25, 2026 10:45
@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch from 0854eca to fa0affc Compare May 25, 2026 11:07
@naoNao89 naoNao89 force-pushed the fix/issue-9292-tail-pseudo-canonicalize branch from 221d29c to 090c811 Compare May 25, 2026 16:13
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.

[Compatibility BUG]. uutils tail breaks update-alternatives when run under pseudo

3 participants