Repository navigation
fix(libc): recover representable snprintf counts at the host limit - #26118
oneandonlydean merged 1 commit into
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the targeted source review supports its stated handling of representable counts and true overflow.
What I ran
Reviewed head 476e2e3b32e3754aeefa78182a03a14f6c164baa. Read the prepared description, commits, manifest and diff, then the changed formatting functions, their guest formatter implementation, and the modified formatting tests using repo_read.py. No tests or builds were run.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Both bounded entry points share the retry path. |
| Tests/build | not run | No commands were run. |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The complete texts of both changed files were available and read. files.json was unavailable through the reader; the manifest lists two changed files, both included and reviewed. Runtime behavior, test results reported in the PR description, and native macOS behavior were not independently verified.
To get this to a good state
Nothing is required.
|
Native macOS check, as the description asks: macOS 27.2.1, Apple M3, x86-64 Release under Rosetta 2, |
|
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.
|
What
Recover a representable guest snprintf result when the host returns EOVERFLOW. Both snprintf and vsnprintf now share the bounded-output path. It saves the argument list before calling the host and retries that one error through the existing guest formatter, which can count the full output while writing only the bytes the caller requested. A total above INT_MAX still returns −1 with EOVERFLOW. Other host errors pass through. Formats with guest-specific conversions, including %n, already take the guest path before the host call.
Issue #26105 reports that the macOS host rejects a result of exactly INT_MAX, which the guest accepts. That makes guest_formatting fail at capacities 0, 1 and 16. The output tests now cover count-only, terminator-only, visible prefix plus padding, and the va_list entry point with a nonliteral width.
Tested
Linux x86-64: guest_formatting passed using the real host libc. I also ran the same CTest with a test-only host vsnprintf replacement that consumes the arguments and returns EOVERFLOW for exactly INT_MAX. The unmodified branch failed at the boundary test. The patch passed. An independent public-export check exercised a representable aggregate count (INT_MAX, written prefix “X ”), true overflow (−1 with EOVERFLOW), a different host error (−1 with EILSEQ), and a single %n write.
The MinGW-w64 build passed
guest_formattingunder Wine. The hosted native Windows job also passedguest_formattingon PR head476e2e3b32and passed all three tests it selected. Windows CI log.#26105 originally reported the failure on macOS 27.0, Apple M4, in an x86-64 Release build under Rosetta 2 with #17425 and #11049 applied.
DiogoPCastelos independently reproduced the failure on
mainatf0b680ce06on macOS 27.2.1, Apple M3, in an x86-64 Release build under Rosetta 2. With this PR’s commit applied,guest_formattingpassed three consecutive runs. The same build also passedguest_wide_formatting,guest_sprintf_s_constraints,guest_avplayer_native_printfandguest_http_dbg_printf. Native macOS test report.The overlap check listed older shared-file branches. I checked #11332's narrow field limits, #9087's secure formatting and scanning constraints, and the scanning changes in #9340, #18380 and #18405. Their bounded snprintf implementations still delegate to the host without handling its EOVERFLOW result.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)