Skip to content

Fix tail -c OOM on large byte counts via stdin#24

Open
kelp wants to merge 1 commit intomainfrom
fix-tail-large-c-oom
Open

Fix tail -c OOM on large byte counts via stdin#24
kelp wants to merge 1 commit intomainfrom
fix-tail-large-c-oom

Conversation

@kelp
Copy link
Copy Markdown
Owner

@kelp kelp commented Mar 31, 2026

Summary

  • tail -c 10000000000 via stdin (pipes, /dev/null) caused OOM because processInputByBytesNoSeek pre-allocated the full byte_count as a circular buffer
  • Cap the circular buffer at 64MB; for larger requests, fall back to a dynamic ArrayList that grows only with actual input data
  • Fixes audit finding F64: all 87 tail integration tests now pass

Test plan

  • zig build test --summary all -- all 1984 unit tests pass
  • just it-util tail -- all 87 integration tests pass (0 failures)

processInputByBytesNoSeek pre-allocated byte_count bytes
unconditionally, causing OOM for values like 10GB even on
empty input. Cap the circular buffer at 64MB and fall back
to a dynamic list that grows only with actual input data.
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.

1 participant