printf: avoid panic on large numeric field widths - #13857
Conversation
|
Binary size comparison: |
| } | ||
|
|
||
| fn write_padding(writer: &mut impl Write, byte: u8, mut len: usize) -> std::io::Result<()> { | ||
| const BUFFER_SIZE: usize = 1024; |
There was a problem hiding this comment.
please document why 1024
sylvestre
left a comment
There was a problem hiding this comment.
Lgtm if the ci is happy
Merging this PR will degrade performance by 18.61%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | df_with_path |
573.7 µs | 704.9 µs | -18.61% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Air-crypto:air-crypto/prinft-large-field-width-fix (bc89833) with main (822aa83)
Footnotes
-
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. ↩
|
GNU testsuite comparison: |
Fixes #13850.
Write numeric field padding in bounded chunks instead of passing widths above
u16::MAXto Rust's formatting machinery. This prevents%65536dfrom panicking and adds a regression test for the expected 65,536-byte output.Tests passed:
cargo test --no-default-features --features printf test_printf::cargo test -p uucorecargo clippy --no-default-features --features printf --all-targets -- -D warningscargo fmt --all -- --check