Skip to content

fix(libc): bound narrow formatting fields - #11332

Draft
Queuse wants to merge 1 commit into
boykopovar:mainfrom
Queuse:codex/fix-windows-narrow-format-bounds
Draft

Queuse wants to merge 1 commit into
boykopovar:mainfrom
Queuse:codex/fix-windows-narrow-format-bounds

Conversation

@Queuse

@Queuse Queuse commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What

Windows narrow printf can misreport oversized fields or fail while formatting even a valid INT_MAX width into a tiny buffer (#11292). Check field bounds and stream padding and precision zeros while retaining the full output count. Overflow returns -1 with guest EOVERFLOW (84).

Draft for integration coordination: #9087 goes first (confirmed) and is still open. The #9958-first order was confirmed and #9958 is now merged; the follow-up must preserve its console long-double mantissa handling. #11341-first is confirmed by its author; #5021-after remains proposed, awaiting confirmation. The rebase after #9087 lands must retain deferred termination in Pad and preserve #11341's portable GuestLongDoubleLoad path when that stack is combined. The published head and its tests below remain unchanged while this order is coordinated.

Tested

Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 UCRT r7, Ninja Release, BUILD_TESTING=ON. Head 793a55b on main 33ae5a3.

  • Rebuilt libc and guest_formatting_tests, guest_wide_formatting_tests, guest_stdio_variadic_tests; all three focused CTests pass.
  • Regressions cover literal/star and positional fields, capacities 0/1/16, sentinels, INT_MAX widths and exact-length precisions, cumulative overflow, negative star precision, typed string arguments and finite/nonfinite floating conversions.
  • 32,400 bounded integer cases match Linux libc; 86,400 double and 31,104 long-double cases preserve baseline results (149,904 comparisons, zero differences).
  • Linux WSL actual-source harness: six moderate floating fields pass with individual allocations over 64 KiB refused; five failed that allocation check before the streaming change. The 32,400-case integer comparison also passes with the formatter compiled directly on Linux.
  • Conventions, public-header audit, test registration and whitespace checks pass.

No full product suite, Linux product build, title or physical-console run. Extreme-field console error behavior remains unmeasured and is recorded in debt/libc.md.

Checklist

@github-actions github-actions Bot added the fix error Closes an issue (Fixes #N) label Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3965 docs/dev/debt/libc.md
PR 5021 core/libs/prx/libc/include/WindowsFormatting.hpp
core/libs/tests/Formatting.cpp
docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6565 docs/dev/debt/libc.md
PR 6819 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7544 docs/dev/debt/libc.md
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 7851 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8397 docs/dev/debt/libc.md
PR 8417 docs/dev/debt/libc.md
PR 8937 docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9466 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9677 docs/dev/debt/libc.md
PR 9761 docs/dev/debt/libc.md
PR 9863 docs/dev/debt/libc.md
PR 9867 docs/dev/debt/libc.md
PR 9873 docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md
PR 9953 docs/dev/debt/libc.md
PR 9964 docs/dev/debt/libc.md
PR 10002 docs/dev/debt/libc.md
PR 10007 docs/dev/debt/libc.md
PR 10113 docs/dev/debt/libc.md
PR 10158 docs/dev/debt/libc.md
PR 10165 docs/dev/debt/libc.md
PR 10200 docs/dev/debt/libc.md
PR 10222 docs/dev/debt/libc.md
PR 10226 docs/dev/debt/libc.md
PR 10229 docs/dev/debt/libc.md
PR 10234 docs/dev/debt/libc.md
PR 10245 docs/dev/debt/libc.md
PR 10247 docs/dev/debt/libc.md
PR 10250 docs/dev/debt/libc.md
PR 10253 docs/dev/debt/libc.md
PR 10265 docs/dev/debt/libc.md
PR 10270 docs/dev/debt/libc.md
PR 10274 docs/dev/debt/libc.md
PR 10315 docs/dev/debt/libc.md
PR 10317 docs/dev/debt/libc.md
PR 10321 docs/dev/debt/libc.md
PR 10324 core/libs/prx/libc/src/Formatting.cpp
docs/dev/debt/libc.md
PR 10325 docs/dev/debt/libc.md
PR 10328 docs/dev/debt/libc.md
PR 10345 docs/dev/debt/libc.md
PR 10349 docs/dev/debt/libc.md
PR 10397 docs/dev/debt/libc.md
PR 10405 docs/dev/debt/libc.md
PR 10506 docs/dev/debt/libc.md
PR 10510 docs/dev/debt/libc.md
PR 10512 docs/dev/debt/libc.md
PR 10565 docs/dev/debt/libc.md
PR 10569 docs/dev/debt/libc.md
PR 10615 docs/dev/debt/libc.md
PR 10620 docs/dev/debt/libc.md
PR 10729 docs/dev/debt/libc.md
PR 10749 docs/dev/debt/libc.md
PR 10780 docs/dev/debt/libc.md
PR 10895 docs/dev/debt/libc.md
PR 10953 docs/dev/debt/libc.md
PR 10987 docs/dev/debt/libc.md
PR 10989 docs/dev/debt/libc.md
PR 11077 docs/dev/debt/libc.md
PR 11109 docs/dev/debt/libc.md
PR 11172 docs/dev/debt/libc.md
PR 11214 docs/dev/debt/libc.md
PR 11260 docs/dev/debt/libc.md
PR 11262 docs/dev/debt/libc.md
PR 11266 docs/dev/debt/libc.md
PR 11298 docs/dev/debt/libc.md
PR 11621 docs/dev/debt/libc.md
PR 11625 docs/dev/debt/libc.md
PR 11632 docs/dev/debt/libc.md
PR 11634 docs/dev/debt/libc.md
PR 11661 docs/dev/debt/libc.md
PR 11664 docs/dev/debt/libc.md
PR 11689 docs/dev/debt/libc.md
PR 11698 docs/dev/debt/libc.md
PR 11726 core/libs/prx/libc/src/Formatting.cpp
core/libs/tests/Formatting.cpp
docs/dev/debt/libc.md
PR 11733 docs/dev/debt/libc.md
PR 11773 docs/dev/debt/libc.md
PR 11793 docs/dev/debt/libc.md
PR 11831 docs/dev/debt/libc.md
PR 11843 docs/dev/debt/libc.md
PR 11848 docs/dev/debt/libc.md
PR 11849 docs/dev/debt/libc.md
PR 11850 docs/dev/debt/libc.md
PR 11870 docs/dev/debt/libc.md
PR 11892 docs/dev/debt/libc.md
PR 11895 docs/dev/debt/libc.md
PR 11907 core/libs/prx/libc/include/WindowsFormatting.hpp
core/libs/prx/libc/src/Formatting.cpp
core/libs/tests/Formatting.cpp
docs/dev/debt/libc.md
PR 11947 docs/dev/debt/libc.md
PR 12053 docs/dev/debt/libc.md
PR 12057 docs/dev/debt/libc.md
PR 12122 docs/dev/debt/libc.md
PR 12149 docs/dev/debt/libc.md
PR 12184 docs/dev/debt/libc.md
PR 12271 docs/dev/debt/libc.md
PR 12292 docs/dev/debt/libc.md
PR 12397 core/libs/prx/libc/include/WindowsFormatting.hpp
core/libs/prx/libc/src/Formatting.cpp
core/libs/tests/Formatting.cpp
docs/dev/debt/libc.md
PR 12428 core/libs/prx/libc/src/Formatting.cpp
core/libs/tests/Formatting.cpp
docs/dev/debt/libc.md
PR 12480 docs/dev/debt/libc.md
PR 12510 docs/dev/debt/libc.md
PR 12511 docs/dev/debt/libc.md
PR 12514 docs/dev/debt/libc.md
PR 12518 docs/dev/debt/libc.md
PR 12532 core/libs/prx/libc/src/Formatting.cpp
core/libs/tests/Formatting.cpp
docs/dev/debt/libc.md
PR 12558 core/libs/prx/libc/src/Formatting.cpp
core/libs/tests/Formatting.cpp
PR 12560 docs/dev/debt/libc.md
PR 12574 docs/dev/debt/libc.md
PR 12586 docs/dev/debt/libc.md
PR 12592 docs/dev/debt/libc.md
PR 12593 docs/dev/debt/libc.md
PR 12594 docs/dev/debt/libc.md
PR 12595 docs/dev/debt/libc.md
PR 12598 docs/dev/debt/libc.md
PR 12605 docs/dev/debt/libc.md
PR 12622 core/libs/prx/libc/include/WindowsFormatting.hpp
core/libs/prx/libc/src/Formatting.cpp
core/libs/tests/Formatting.cpp
docs/dev/debt/libc.md
PR 12627 docs/dev/debt/libc.md
PR 12682 docs/dev/debt/libc.md
PR 12688 docs/dev/debt/libc.md
PR 12700 docs/dev/debt/libc.md
PR 12704 docs/dev/debt/libc.md
PR 12841 docs/dev/debt/libc.md
PR 12849 docs/dev/debt/libc.md
PR 12920 docs/dev/debt/libc.md
PR 12947 docs/dev/debt/libc.md
PR 12965 docs/dev/debt/libc.md
PR 13186 docs/dev/debt/libc.md
PR 13390 docs/dev/debt/libc.md
PR 13442 docs/dev/debt/libc.md
PR 13449 docs/dev/debt/libc.md
PR 13499 docs/dev/debt/libc.md
PR 13678 docs/dev/debt/libc.md
PR 13732 docs/dev/debt/libc.md
PR 13783 docs/dev/debt/libc.md
PR 13784 docs/dev/debt/libc.md
PR 13793 docs/dev/debt/libc.md
PR 13794 docs/dev/debt/libc.md
PR 13804 docs/dev/debt/libc.md
PR 13809 docs/dev/debt/libc.md
PR 13819 docs/dev/debt/libc.md
PR 13828 docs/dev/debt/libc.md

@MarcZX10

Copy link
Copy Markdown
Contributor

I checked the exact head 793a55ba18 against the current main (9b197b6ce4). tools/check_main_sync.py reports the PR is 1 commit ahead and 37 behind its merge base 33ae5a314, although git merge-tree currently merges it cleanly. The posted focused test report is against that older base. Because this rewrites the formatter and overlaps the still-open #9087/#9958/#10379 stack, please confirm the intended merge order and refresh onto current main once those prerequisites are integrated, then rerun the focused formatting tests on the resulting exact head. Current hosted checks pass, but the Linux and Windows product jobs are path-skipped.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I inspected the live overlap rather than relying only on the bot table. A two-head git merge-tree preview between this head (793a55ba18) and #11341 (fcb72551ab) conflicts in WindowsFormatting.hpp. #11341 changes FormatArguments::Next<long double> to use GuestLongDoubleLoad and removes the native-long-double layout assertions; this formatter rewrite must preserve that portable long-double path when the two changes are combined. Please coordinate the order with #11341’s author and record the dependency/order in the checklist. The #9958-first / #5021-after order is still marked pending in this draft, so keep it explicit as those authors confirm it; I am not asking anyone to close a PR.

The branch is also 1 ahead and 92 behind current main (fdb3925940), with a clean merge preview but docs/dev/debt/libc.md changed on both sides since the base. CONTRIBUTING says to keep branches current; please rebase after the stack order is settled, preserve the overlapping debt edits, and rerun the focused Windows formatters and local overlap/convention checks on that exact head. I am not approving this draft before those integration and current-head checks.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 26, 2026
@Queuse

Queuse commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

I have recorded the new overlap and the proposed #11341-first order. #9958's author confirmed its order and it has now merged. #9087 remains open, so I am following the requested sequence: keep this draft at 793a55ba18, then refresh after that prerequisite lands and rerun the focused formatting tests on the resolved head. That resolution must preserve console long-double digits, bounded emission, deferred Pad termination and the portable long-double load when combined with #11341. The description now distinguishes confirmed, fulfilled and pending orders; its existing test results still refer to the published head.

@Queuse

Queuse commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

#11341's author has now confirmed #11341 → #11332, and I have recorded it as agreed in the description/checklist. #9087 and #11341 are still open, so this draft remains at 793a55ba18 pending those prerequisites. The later rebase will retain GuestLongDoubleLoad, host-layout independence, the console mantissa rules and deferred Pad termination, then rerun the focused tests. #5021-after remains a separate proposal awaiting confirmation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs fix error Closes an issue (Fixes #N) libc needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libc: narrow snprintf on Windows crashes or misreports on a width or precision beyond int

2 participants