Skip to content

tail: do not abort on -c +N when the start offset is past the seek limit - #14091

Open
SAY-5 wants to merge 1 commit into
uutils:mainfrom
SAY-5:tail-fix-seek-past-limit
Open

tail: do not abort on -c +N when the start offset is past the seek limit#14091
SAY-5 wants to merge 1 commit into
uutils:mainfrom
SAY-5:tail-fix-seek-past-limit

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #13887.

tail -c +N on a regular file larger than the block size seeks to byte N-1. When that offset is past the largest seekable position the underlying lseek returns EINVAL, and the .unwrap() aborted the process (exit 134). GNU treats a start byte past the end of the file as empty output.

This falls back to seeking to the end of the file when the initial seek fails, mirroring the existing handling in the negative-bytes arm, so the request produces no output instead of crashing.

Added a regression test that runs tail -c +<huge> FILE on a file larger than the block size and expects success with empty output.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cp/link-heap is now passing!

@codspeed-hq

codspeed-hq Bot commented Aug 23, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.02%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 356 untouched benchmarks
⏩ 50 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_wide_tree[(5000, 500)] 19.4 ms 20 ms -3.02%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing SAY-5:tail-fix-seek-past-limit (2466ccd) with main (9875296)

Open in CodSpeed

Footnotes

  1. 50 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.

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.

tail panics (aborts) on -c +N with a very large N (seek .unwrap() on EINVAL)

1 participant