Skip to content

printf: avoid overflow for minimum dynamic width - #13795

Open
subotac wants to merge 1 commit into
uutils:mainfrom
subotac:fix/printf-min-width-overflow
Open

printf: avoid overflow for minimum dynamic width#13795
subotac wants to merge 1 commit into
uutils:mainfrom
subotac:fix/printf-min-width-overflow

Conversation

@subotac

@subotac subotac commented Aug 7, 2026

Copy link
Copy Markdown

Fixes #13766.

Resolving a negative dynamic width negated the signed argument directly, which overflows for i64::MIN. Use unsigned_abs() so the value reaches the existing width handling safely, and add a regression
test for the minimum signed value.

@codspeed-hq

codspeed-hq Bot commented Aug 7, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.18%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 345 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_max_depth_balanced_tree[(6, 4, 10)] 62.8 ms 60.2 ms +4.28%
Simulation du_summarize_balanced_tree[(5, 4, 10)] 16.2 ms 15.5 ms +4.09%

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 subotac:fix/printf-min-width-overflow (0908384) with main (371b24a)

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 Aug 7, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/cut/mb-non-utf8 is no longer failing!
Congrats! The gnu test tests/mv/mv-exchange is no longer failing!
Congrats! The gnu test tests/od/od-j is no longer failing!
Congrats! The gnu test tests/dd/no-allocate is now passing!
Note: The gnu test tests/misc/write-errors was skipped on 'main' but is now failing.

@sylvestre

Copy link
Copy Markdown
Contributor

Please also add a test in test_printf.rs

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.

printf: arithmetic overflow (overflow-checks) on a %*d dynamic field width of i64::MIN

2 participants