Skip to content

feat(libc): implement bounded decimal parsing with strtonum - #8037

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
MarrasFederico:feat/libc-strtonum
Oct 20, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
MarrasFederico:feat/libc-strtonum

Conversation

@MarrasFederico

Copy link
Copy Markdown
Contributor

What

Add the missing strtonum export (XrIfmNFHL4I) to libc. Parse decimal signed 64-bit values within inclusive caller bounds, return invalid, too small or too large on failure, and preserve the caller's errno on success. Malformed input takes precedence over overflow, and reversed bounds are rejected before parsing.

The signature and behavior follow FreeBSD 11.4 strtonum.c. The name/NID pair is present in the pinned symbol database. Console behavior remains unverified and is recorded in libc technical debt.

No matching open or closed PR, issue, or origin/main symbol-history change was found. pr_overlap.py reported no direct overlaps. Its not-compared shared files were reviewed manually: #5021, #5303, #6226, #6469, #6819, #7081, #7332, #7386, #7417, #7473, #7525 and #7715 change unrelated libc debt entries; #6044 only renames GuestStrings.cpp into tests/runtime/ with zero content changes. None implements or tests strtonum.

Tested

Ubuntu 26.04 x86-64, GCC 15.2.0, Release, BUILD_TESTING=ON:

  • Initialized all recursive submodules and completed the full build with -j12.
  • The new semantic regression cannot link against the original libc because strtonum_nid_postfix is absent.
  • guest_strings, guest_wide_strings, guest_errors, guest_safe_errors and guest_allocating_strings pass.
  • Seven temporary production-source mutations are detected by guest_strings: reversed-bound validation, trailing-character rejection, signed underflow, signed overflow, successful errno preservation, successful error-pointer clearing, and failure errno assignment.
  • The patched libc exports XrIfmNFHL4I.
  • Conventions, whitespace and overlap checks completed. The not-compared cases are described above.

No title, console, Windows or macOS execution was tested. No performance claim.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Progress report (98db779 → 20f75e9)

📈 System libraries: 66.63% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc strtonum_nid_postfix

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 8137 docs/dev/debt/libc.md L4-5

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 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6044 core/libs/tests/GuestStrings.cpp
PR 6226 docs/dev/debt/libc.md
PR 6469 docs/dev/debt/libc.md
PR 6819 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7332 docs/dev/debt/libc.md
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7473 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md

@wachi35676

Copy link
Copy Markdown
Contributor

Windows run (the description has Linux only): Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. This PR merged onto main 9127ea3.

  • It builds.
  • guest_strings passes 3/3, including the errno-preservation checks through __error_nid_postfix, so the host errno the function sets is the one the guest reads on MinGW too.
  • With StringExtensions.cpp from main the test doesn't link, as on Linux.
  • The body matches FreeBSD 11.4 strtonum.c step for step: the minval > maxval check first, then strtoll base 10, the INVALID / TOOSMALL / TOOLARGE order, *errstrp set even on success, and errno restored on success.
  • strtonum hashes to XrIfmNFHL4I.

AI-assisted: yes (Claude Code); results above were run on this machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 20, 2026
# Conflicts:
#	core/libs/tests/GuestStrings.cpp
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@oneandonlydean
oneandonlydean merged commit 4a10f5f into boykopovar:main Oct 20, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants