uutils / uutils/coreutils

Fixing flaky cut bounded memory test

Open
#13,990 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - cut
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/cut/bounded-memory and the cut paths using bstr::BufReadExt::for_byte_record*. Trace how BufRead::fill_buf could support incremental selections, then add deterministic endless-reader and failing-writer tests. Done means the relevant selections produce output without timeout-based behavior or buffering an endless record.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, performance, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.