Skip to content

fix: csplit --suffix-format huge field width panics instead of erroring#13256

Open
mvanhorn wants to merge 1 commit into
uutils:mainfrom
mvanhorn:fix/12763-csplit-suffix-format-width-panic
Open

fix: csplit --suffix-format huge field width panics instead of erroring#13256
mvanhorn wants to merge 1 commit into
uutils:mainfrom
mvanhorn:fix/12763-csplit-suffix-format-width-panic

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

csplit no longer panics when --suffix-format requests an enormous field width. A format like --suffix-format=%0999999999d now returns a clean error instead of aborting with a Rust panic, because the split-name formatter propagates the formatting error rather than unwrapping it.

Why this matters

Issue #12763 reports that csplit panics on a --suffix-format with a very large field width. SplitName::get used write!/format! and unwrapped the result; for a pathological width the formatter allocation/formatting failed and the unwrap turned that into a panic, crashing the utility instead of reporting a usage error the way GNU csplit does.

The formatter now returns io::Result<String> and the caller surfaces a proper csplit error, so an unusable suffix format is rejected with a message and a non-zero exit rather than a panic.

Testing

cargo test -p uu_csplit passes, including a new test_csplit case asserting that a huge --suffix-format width errors out (non-zero exit, no panic) instead of crashing. cargo clippy -p uu_csplit is clean.

Fixes #12763

@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.88%

⚡ 1 improved benchmark
✅ 330 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation sort_ascii_utf8_locale 16.1 ms 15.4 ms +4.88%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mvanhorn:fix/12763-csplit-suffix-format-width-panic (d65969e) with main (df0701c)

Open in CodSpeed

Footnotes

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

@github-actions

github-actions Bot commented Jul 3, 2026

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)
Skip an intermittent issue tests/misc/tty-eof (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cp/link-heap is now being skipped but was previously passing.

@sylvestre

Copy link
Copy Markdown
Contributor

sorry but could you please rebase it ? thanks

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.

csplit: --suffix-format with a huge field width panics (Result::unwrap on a formatter error)

2 participants