Repository navigation
Fix table --abbreviated crash when the row count is too large to allocate - #19296
Conversation
`table --abbreviated` reserved the head and tail buffers with the requested row count, so a count too large to allocate panicked with a capacity overflow. The buffers only hold the rows that are actually read, so let them grow instead. Add tests that a huge count prints the same table as a normal one. Signed-off-by: G. Manoj Kumar <[email protected]>
table --abbreviated crash when the row count is too large to allocatetable --abbreviated crash when the row count is too large to allocate
|
You've added several PRs that change |
Reserve the head and tail buffers with the smaller of the requested count and the stream's size hint, so a huge count no longer panics but inputs with a known length still allocate once. Signed-off-by: G. Manoj Kumar <[email protected]>
|
Probably all your other PRs that do the same thing need to be investigated this way too. What do you think? |
There was a problem hiding this comment.
Review overview
🟡 Changes recommended
The size.min(size_hint().0) cap fixes the panic for lists, ranges and streams, and the record path was already safe. The notes below make the reservation match what each buffer can hold and point the tests at the list input that actually uses the hint. None of them block the merge.
Findings: 0
Open (5)
tailreserves slots it can never fillheadstill reallocates twice when rows are cut Neither new test runs with a non-zero size hint The range test repeats whattable_abbreviation_cutchecks PR description describes the first commit. The second paragraph still says the buffers "now start empty and grow". Since 565fb35 they reservesize.min(size_hint().0), so the description and the release-notes reasoning should say that.
Notes from my clanker, checked on 565fb35. Read-only, branch not built; CI root jobs pass on Linux and Windows (macOS pending). The size hints were read from range.rs, list_stream.rs and every.rs, and {a: 1, b: 2} | table -a 9223372036854775807 prints normally on 0.116.2 while [[a]; [1]] | table -a 9223372036854775807 panics there, as the PR says.
Reserve the tail only for the rows left after the head, and the head for its final length (the first rows, the `...` row and the tail), so a cut table does not reallocate either buffer. Test a plain list, which has a size hint, and drop the range test that repeats what the cut test already checks. Signed-off-by: G. Manoj Kumar <[email protected]>
Add the huge-count range case as one more assertion in `table_abbreviation_cut` and name the two new tests with the file's `table_abbreviation_` prefix. Signed-off-by: G. Manoj Kumar <[email protected]>
|
answering the other concerns here :
yes, fair. went through them again:
|
|
Thanks |



Description
table --abbreviatedcrashes when the count is too large to allocate. On current main:stream_collect_abbreviatedreserves the head and the tail withwith_capacity(size), wheresizeis the number the user typed. Both buffers only ever hold rows that are actually read, so they are now sized from the iterator's size hint:headreserveshint.min(2 * size + 1), which is its final length with the...row, andtailreserveshint.saturating_sub(size).min(size). Inputs without a hint, like a range orevery, start empty and grow.The output doesn't change: a count larger than the input shows every row, as before. This is the same problem as #19286 (
chunks), #19288 (window) and #19295 (last).I added tests that a huge count prints the same table as a normal count, for a plain list and for a list stream, and a huge-count range case in
table_abbreviation_cut. I ran thetable::abbreviationtests locally and they pass. I did not run the full workspace suite.AI assistance: I used Claude to help find the issue and draft the change. I reviewed and tested it myself.
User-facing changes (Release notes)
Fixed a crash when
table --abbreviatedis given a row count too large to allocate, such as 9223372036854775807.Additional notes
n/a