fix(libc): retain short wide scanf character fields #9863
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9863"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T19:38:19Z.
What
Keep a nonempty character field when wide scanf reaches EOF before its requested width. Input
awith%3lcreturns one assignment, stores onlyawithout a terminator, and continues to%nor a following directive. Suppression consumes the prefix without adding an assignment; an empty field remains an input failure. Positive-capacity secure wide destinations consume at mostmin(width, capacity). For positive-length input, a zero-capacity wide destination adds no assignment, leaves output/errno unchanged and stops before the following%n.Short-field behavior follows pinned FreeBSD11.4 convert_char/convert_wchar, supplemented by hypermoist's report and JJenkx's native calls to three bundled libraries. These are attributed contributor measurements, not my console measurements or firmware-wide proof. Zero-capacity consumption/empty-input precedence, narrow byte-capacity rules and native stream parity remain unverified in debt. The reported undersized narrow ASCII case remains a known gap; no test pins its unsupported exception behavior.
The review refresh retains main's public declarations, UTF-8 and
%S/%Cmatching-failure behavior and one combined scanner debt bullet. Blazing Cook's positive-capacity contribution retains its author identity/history. The agreed order remains #9863 before #9087; names, NIDs and implemented ABI do not change.Tested
Review revision
5f290cecde56468bb507d4c72b9de50c03eeab87, based on main47f9cee2cd77by history-preserving merge.Hosted Linux actual project configure/focused build passed with matching source-built libraries: both scanner suites pass once plus five repetitions each. Conventions (0 errors; existing combined debt-length warning), whitespace, public-header audit and standalone libc/kernel header compilation pass. Linux job. Windows final-head actual project configure/affected-target build passed on hosted WinLibs GCC 15.2 Release with matching runtime libraries: 2/2 focused tests, followed by two repetitions each. Windows job. Git-only mergeability against later fetched main
504ea3b53b23is clean; that later combined tree was not built.Original Windows baseline/candidate and later independent contributor results remain recorded in the earlier review report and zero-capacity correction; those are historical heads, not additional final-head platform runs.
No local builds/runtime tests, games, proprietary modules or physical-console execution were performed for this revision. The full repository suite was not run.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T20:15:54Z.
Review: COMMENTED
I reviewed the implementation path and the added regressions against the contributor-reported bundled-library table in #9321. The code now assigns the consumed nonempty
%c/%lcprefix without a terminator, continues to later directives and%n, and leaves suppressed fields unassigned. Tests cover both string and stream scanners, secure/unsecure entry points, prior assignments, exact canary bounds, lookahead and an explicitly unsupported undersized secure-capacity case. The debt text keeps the evidence attribution and remaining limits clear. The coordinated order with #9087 is documented by both authors, andDepends on: noneis consistent with the confirmed independent order.The author reports Windows focused builds/runs and 8/8 candidate suites (9/9 including loader) against identical executables, plus 1177 test registrations. Hosted conventions, relinker and registration checks pass; hosted Linux/Windows product jobs are skipped. I did not independently run the Windows binaries here.
One freshness item: current upstream
mainisa0900b9d; GitHub compare reports head26db0f2ais two commits ahead and 26 behind, with merge based6e7ab42. CONTRIBUTING asks branches to stay current. Please rebase, preserve the agreed #9087 wording/order, and rerun the two focused scanner suites plus conventions on the final combined head before merge. No blocking behavior defect found in the reviewed diff.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T14:18:33Z.
Review: CHANGES_REQUESTED
I reviewed exact head
12446569274e168eb8e14d2bc86205b7e2d02492.One measured secure-field case is still represented as an exception, although the linked native-library results report a return value:
ScanningWide.cpp:432-433throws when%3lchas a positive-length short input and capacity zero.GuestWideConversion.cpp:259-264codifies that as an expected throw.libc.prxbuilds,swscanf_s(L"a", L"%3lc%n", w, 0, &n)returns0, leaves the destination untouched, leaveserrnoat zero, and does not reach%n. The report explicitly leaves input consumption unknown.Please make the zero-capacity short-field return and destination behavior match that evidence, and add a regression that checks those observed results without asserting stream/input consumption. Keep consumption marked unverified until measured. The current explicit throw is a known behavior mismatch, even though the cursor position is unknown.
The exact-head report records strong Linux validation (10/10 focused suites, including five repeat runs); I did not rerun those tests locally. Current hosted Linux and Windows product jobs are skipped, while conventions, eligibility, registration, relinker matrix and other applicable checks pass. The PR is also 8 commits behind current
main(e94545a5, merge base938812df); the merge is clean, and those intervening main commits do not touch the four changed files. Please refresh to currentmainand rerun both focused scanner suites and conventions before merge, as required by the contribution rules.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:18:35Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The zero-capacity short-field finding from my earlier review is resolved: the tests now pin the measured assignment count/output/
errnobehavior, the stale debt sentence is removed, and the author reports focused Linux and Windows runs on the current feature head. I found no new implementation defect in that fix.Two readiness items remain. First, the #12420 author proposed #9863 first, and the #12514 author independently proposed the same order for the debt-file overlap. Please confirm that order so the follow-up authors can record their dependencies. Second, current
mainhas advanced since this branch’s last merge;docs/dev/debt/libc.mdchanged on both sides, even though the merge preview is currently clean. Please reconcile the debt entry against current main and rerun the documented checks on the integrated head.The focused scanner tests and policy checks are reported green; I did not run them locally. This request is for the unconfirmed overlap order and current-main integration, not the resolved zero-capacity behavior.