The GNU tests/cut/bounded-memory result currently flakes. In a failing run, cut -c1, cut -f1, and cut -s -f2 reading from /dev/zero aborted after an 8 MiB allocation failed.
These paths use bstr::BufReadExt::for_byte_record*, which buffers an entire record before processing it. Since /dev/zero never contains a newline, memory grows without bound.
The flakiness comes from the test’s 0.5-second timeout: on a slower or busier runner, the timeout kills cut before it reaches the memory limit; on a faster runner, allocation fails first.
What do you think about:
- Process byte and character selections incrementally using BufRead::fill_buf, retaining only position state across chunks.
- Stream field selections when this is unambiguous—particularly with -s, or when field 1 is selected.
- Keep the existing record-buffered path for cases such as cut -f2 without -s, where output cannot be decided until a delimiter or end-of-record is observed.
- Add deterministic unit tests using an endless reader and a writer that intentionally fails after receiving output. This verifies that output is produced without first consuming or buffering an entire record, without relying on timeouts or OS memory limits.
If this sounds good I can implement
The GNU tests/cut/bounded-memory result currently flakes. In a failing run, cut -c1, cut -f1, and cut -s -f2 reading from /dev/zero aborted after an 8 MiB allocation failed.
These paths use bstr::BufReadExt::for_byte_record*, which buffers an entire record before processing it. Since /dev/zero never contains a newline, memory grows without bound.
The flakiness comes from the test’s 0.5-second timeout: on a slower or busier runner, the timeout kills cut before it reaches the memory limit; on a faster runner, allocation fails first.
What do you think about:
If this sounds good I can implement