Skip to content

feat(libc): wire the numpunct<char> facet vtable and its members - #21930

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
Herolias:feat/numpunct-char-facet
Nov 26, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
Herolias:feat/numpunct-char-facet

Conversation

@Herolias

Copy link
Copy Markdown
Contributor

What

libc exports the numpunct<char> vtable (_ZTVSt8numpunctIcE, NID lJnP-cn0cvQ) as eleven uintptr_t slots, and on main all eleven are zero. The console's libc.prx also exports the facet's six constructors, three destructors, _Init and _Tidy (ps5rs libc.txt), and main's libc exports none of them. This change fills slots 2 to 10 and adds those eleven exports to libc. It is the piece #21537's description listed as missing: "the exported numpunct<char> constructors are absent, so nothing builds a facet on the exported object yet".

How code reaches it: Dinkumware defines all six constructors, the destructor and _Init inside the class (crt.vc12 xlocnum lines 72-228), so a guest that constructs a numpunct<char>, or a class derived from it, writes the exported vtable into the object and calls these members either inline or through the libc imports. On main any call through that vtable faults, and the libc imports of the constructors and destructors are absent. I know of no title that does this. None of the eight title import lists (#265-#272) holds one of the twelve NIDs, but those lists name only the NIDs that were new when they were posted, so that shows nothing either way. This PR claims no unblocked title. Like #21170 (messages<char>) and #21537 (ctype<char>), it completes an exported vtable from sourced code.

  • Vtable: slots 2 to 10 hold the complete and deleting destructors, RetainFacet and ReleaseFacet (the _Incref/_Decref of libc's other facets), and then do_decimal_point, do_thousands_sep, do_grouping, do_falsename and do_truename, which main already implements. That is the Itanium order of _Facet_base's virtuals followed by numpunct's (microsoft/STL xfacet lines 26-36, xlocnum lines 160-222) and the order GuestLocale::NumpunctVtable already records. Offset-to-top and typeinfo stay zero, as in the other filled vtables.
  • _Init (1LvbNeZZJ-o): follows crt.vc12 xlocnum lines 161-188 and microsoft/STL lines 181-202. It nulls the three string pointers, then copies localeconv()'s grouping (or "" when _Isdef is set), "false" and "true" into new blocks. If an allocation fails it runs _Tidy and rethrows. It then takes . and , when _Isdef is set, and otherwise the first byte of localeconv()'s decimal point and thousands separator. _Locinfo::_Getlconv, _Getfalse and _Gettrue are inline in both sources and return localeconv(), "false" and "true" (crt.vc12 xlocinfo lines 125-128 and 165-173), so _Init never reads the _Locinfo object itself. main's localeconv() is a fixed C-locale table read from Astro's Playroom's libc.prx (libc.md, localeconv), which holds the same "false" and "true" in its _False/_True fields.
  • Allocation: the blocks come from operator new[] and _Tidy (fFnht9SPed8) releases them with operator delete[], as V6.00's _Maklocstr and _Tidy do (crt.vc12 xlocale lines 724-738, xlocnum lines 216-221). microsoft/STL uses calloc and free instead (xlocale lines 563-579, xlocnum lines 225-229). The console's libc is Dinkumware's, so I followed the Dinkumware release where the two differ; in this library free and operator delete[] both release through the application heap (FileAndHeap.cpp line 1001, StdioExtras.cpp line 143).
  • Constructors (TEtyeXjcZ0w/1eVdDzPtzD4 (size_t), CDm+TUClE7E/Cb1hI+w9nyU (const _Locinfo&, size_t, bool), WK24j1F3rCU/yIn4l8OO1zA (const char*, size_t, bool)): each stores the vtable and the reference count, truncated to the facet's 32-bit counter (locale::facet(size_t), crt.vc12 xlocale lines 160-163), then follows crt.vc12 xlocnum lines 107-145:
    • (size_t) builds a default _Locinfo, which is "C" (xlocinfo line 71), runs _Init with _Isdef false and replaces a zero thousands separator with ,;
    • (const _Locinfo&, size_t, bool) runs _Init with the given _Isdef;
    • (const char*, size_t, bool) builds _Locinfo from the name and runs _Init. _BEGIN_LOCINFO is that _Locinfo in a scope (crt.vc12 yvals.h lines 762-767). main's _Locinfo accepts only "C" and throws std::invalid_argument otherwise, so these constructors do too, before allocating anything.
      The C1 and C2 forms are the same function, as the Itanium ABI allows for a class without virtual bases. The mangled names fix the parameter types (m is unsigned long, b is bool; compute_nid of each name gives its NID).
  • Destructors (qEob3o53s2M D1, xFva4yxsVW8 D2, Lf6h5krl2fA D0): ~numpunct runs _Tidy (crt.vc12 xlocnum lines 134-137), and the deleting destructor then frees the facet with operator delete.
  • How the eleven are exported: seven use libc's usual _nid_postfix names. libSceLibcInternal already defines _ZNSt8numpunctIcEC1EPKcmb, _ZNSt8numpunctIcEC2ERKSt8_Locinfomb and _ZNSt8numpunctIcED0Ev with that suffix (InventoryExports6.cpp), which check_conventions rejects as duplicate-export, and exports D2's NID as sceLibcInternalUnknown6_119_xFva4yxsVW8, which it rejects as unknown-nid. Those four are _nid_no_patch bodies exported with APS5_EXPORT, as libc already does for __cxa_finalize (b8a1cbe). libSceLibcInternal is unchanged: libc imports never fall back to it (WindowsEntryStubBuilder.cpp lines 180-215), and its own numpunct<char> members stay as they are on main.
  • _Getcat is unchanged. It still builds its C-locale facet on libc's internal table with static strings (the libc.md _Getcat entry), so facets from use_facet through libc's _Getcat never reach the new destructors.

What still throws, and why:

  • A null facet passed to any of the eleven throws std::invalid_argument, where the console would fault. This is the host-safety policy of the ctype<char> destructors.
  • The named constructors throw std::invalid_argument for any name other than "C", because main's _Locinfo does.
  • No path calls NotImplemented_nid_no_patch.

Debt: docs/dev/debt/changes/feat-numpunct-char-facet.md changes the libc.md "numpunct vtable" entry, which said the slots are zeroed, and adds two Functional entries for _Init/_Tidy and for the constructors and destructors. Each entry is under 1000 characters (914, 897 and 922).

Overlap:

Not in this PR:

  • numpunct<char>'s typeinfo _ZTISt8numpunctIcE (ddLNBT9ks2I). main exports no facet typeinfo, locale::facet's included, and feat(libc): expose 345 read-only runtime data exports #13449 adds the _ZTS name. A guest class derived from numpunct<char> with RTTI needs it.
  • The numpunct<wchar_t> vtable (Gtsl8PUl40U), which main's libc does not export at all. Both sources take the wide decimal point and separator from lconv's _W_decimal_point and _W_thousands_sep (crt.vc12 xlocnum lines 154-159, microsoft/STL xlocnum lines 176-179), and the 0x90-byte lconv of the console's libc has no such fields (SonyLconv in core/libs/SceTypes.hpp), so neither source says where the console's _Init gets them.
  • libSceLibcInternal's numpunct<char> members.

Tested

Fedora Linux 44, GCC 16.2.1, GNU ld 2.46.1, CMake 4.3.0, Ninja 1.13.2, Release build with -DBUILD_TESTING=ON, on 913524c1ee (based on main at ec9f142628). No title, no console and no Windows host.

  • Full build: passes.
  • tools/select_tests.py selects 5776 of 5883 tests for this change. 5775 pass and 62 of them skip themselves on this NVIDIA machine. The one failure is agc_driver_image_table_packed_guards ("deferred write-back failed: image table ... invalid format"). It fails the same way with main's copies of this branch's five changed files that exist on main checked out and only that test rebuilt, so it comes from main.
  • guest_numpunct_facet (new) runs _Init and _Tidy through both entry points with _Isdef set and clear, fails each of the three allocations in turn, and runs every constructor and destructor export, the vtable slots and the null-facet checks against a recording application heap. guest_locale now checks the filled vtable slots on a facet built by numpunct(size_t) instead of checking that they are zero. Both pass.
  • patched_self_imports passes, and nm -D on the patched libc.prx lists all twelve NIDs (the vtable as data, the eleven members as text).
  • Negative controls: 24 single mutations of LocaleSupport.cpp, each built and run with guest_locale and guest_numpunct_facet. Among them are a zeroed vtable, swapped vtable slots, a missing reference count, _Tidy leaking or reordering, _Init sharing the lconv grouping, keeping stale pointers, leaking or swallowing a failure, and constructors ignoring _Isdef or the name. 23 fail at least one test. The survivor makes numpunct(size_t) call _Init with _Isdef set. That is equivalent here, because main's localeconv() is a fixed C-locale table (empty grouping and separator, .), so _Init with _Isdef clear followed by the , fallback builds the same facet. The tests pass again with the code restored.
  • The recording heap sees free, operator delete and operator delete[] as the same release, so the tests check which blocks are released and in which order, not which of the three functions releases them.
  • x86_64-w64-mingw32-g++ 16.2.1 -fsyntax-only with -D_UCRT -D__MSVCRT_VERSION__=0xE00 passes for LocaleSupport.cpp, GuestLocale.cpp and GuestNumpunctFacet.cpp. Nothing ran on Windows.
  • python3 tools/check_conventions.py --base origin/main passes, and python3 tools/debt_fold.py --check passes.

Sources

Behaviour Source
Slot count and header: 11 slots, with offset-to-top, typeinfo, two destructors and _Incref/_Decref first st_size 88 measured on PPSA26344's libc.prx, recorded in the libc.md "numpunct vtable" entry
Order of the destructor, _Incref, _Decref and the five do_* virtuals microsoft/STL 219514876e stl/inc/xfacet lines 26-36, stl/inc/xlocnum lines 160-222; ganboing/crt.vc12 f1d47126bf src/xlocnum lines 134-213
_Init: null the strings, copy grouping (or ""), "false", "true"; _Tidy and rethrow on failure; ./, with _Isdef, else the first byte of the decimal point and separator crt.vc12 src/xlocnum lines 147-188; microsoft/STL stl/inc/xlocnum lines 170-202
_Getlconv, _Getfalse, _Gettrue return localeconv(), "false", "true"; the default _Locinfo is "C" crt.vc12 src/xlocinfo lines 71, 125-128, 165-173; microsoft/STL stl/inc/xlocinfo lines 68, 124-126, 158-164
Strings in operator new[] blocks released with operator delete[] (microsoft/STL: calloc/free) crt.vc12 src/xlocale lines 724-738, src/xlocnum lines 216-221; microsoft/STL stl/inc/xlocale lines 563-579, stl/inc/xlocnum lines 225-229
Constructors: reference count, (size_t) with a "C" _Locinfo and the , fallback, (const _Locinfo&), (const char*) crt.vc12 src/xlocnum lines 107-145, src/xlocale lines 160-163, src/yvals.h lines 762-767; microsoft/STL stl/inc/xlocnum lines 137-168, stl/inc/xlocale lines 152-154
Destructors run _Tidy; the deleting one then frees the facet crt.vc12 src/xlocnum lines 134-137; Itanium C++ ABI 5.1.4, "deleting destructor"
Facet layout (grouping 0x10, decimalPoint 0x18, thousandsSep 0x19, falsename 0x20, truename 0x28) and 32-bit reference count GuestLocale::NumpunctFacet and GuestLocale::Facet in core/libs/prx/libc/include/GuestLocale.hpp on main, recorded in the libc.md _Getcat entry (console libc.prx)
libc exports the vtable and the eleven members claimore22/ps5rs 2304be5131 data/stubs/by_library/libc.txt lines 144, 161, 672, 687, 1074, 1436, 1567, 1983, 2271, 2490, 2801, 2842
Parameter types the mangled names; tools/check_conventions.py compute_nid gives each listed NID from its name
A libc.prx import resolves only in libc among AnyPS5's libraries core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp lines 180-215
APS5_EXPORT for a NID whose name another library declares core/libs/prx/libc/Export.cpp line 20 (__cxa_finalize, b8a1cbe)

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

Fill libc's exported numpunct<char> vtable and export the facet's
constructors, destructors, _Init and _Tidy, following Dinkumware's
numpunct (crt.vc12 xlocnum, microsoft/STL xlocnum). _Init copies the
C-locale grouping and the false and true names into operator new[]
blocks, the size_t constructor turns a zero separator into ',', and
the destructors release the three blocks before the deleting one frees
the facet.

Four of the exports go through APS5_EXPORT because libSceLibcInternal
already declares their names or exports their NID as an Unknown alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@PrivacyOnion PrivacyOnion 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.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 913524c1ee:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_locale_tests, guest_numpunct_facet_tests built cleanly.
  • CTest (guest_locale, guest_numpunct_facet):
    1/2 Test #1340: guest_locale .....................   Passed    0.02 sec
    2/2 Test #1341: guest_numpunct_facet .............   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/include/GuestLocale.hpp, core/libs/prx/libc/src/LocaleSupport.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified _ZTVSt8numpunctIcE_nid_postfix vtable layout (11 slots, slots 0-1 zero, slots 2-10 matching Dinkumware / libc facet ABI order) and NumpunctVtable offsets
    • Audited NumpunctInit_nid_no_patch, NumpunctTidy_nid_no_patch, and MakeNumpunctString memory handling and exception safety during heap allocation
    • Checked null pointer validation across all new exported constructors, destructors, Init, and Tidy methods (_ZNSt8numpunctIcE* and Numpunct*), verifying APS5_INVALID_ARG_EX guards
    • Verified technical debt fragment docs/dev/debt/changes/feat-numpunct-char-facet.md format and documentation of C-locale fallback and invalid_argument behavior
    • Audited test coverage in GuestNumpunctFacet.cpp and GuestLocale.cpp covering C1/C2 constructors, D1/destroy/deleteObject destructors, reference counting, allocation failure recovery, and null arguments

Looks Good To Me

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Progress report (102cad6 → caf99e0)

📈 System libraries: 46.95% (+0.01%, +11 implemented functions)

✅ 11 implemented
Library Name
libc NumpunctConstructFromLocinfo_nid_no_patch
libc NumpunctConstructNamed_nid_no_patch
libc NumpunctDelete_nid_no_patch
libc NumpunctDestroy_nid_no_patch
libc _ZNSt8numpunctIcE5_InitERKSt8_Locinfob_nid_postfix
libc _ZNSt8numpunctIcE5_TidyEv_nid_postfix
libc _ZNSt8numpunctIcEC1ERKSt8_Locinfomb_nid_postfix
libc _ZNSt8numpunctIcEC1Em_nid_postfix
libc _ZNSt8numpunctIcEC2EPKcmb_nid_postfix
libc _ZNSt8numpunctIcEC2Em_nid_postfix
libc _ZNSt8numpunctIcED1Ev_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libc 1858/1866 (99.57%) 1869/1877 (99.57%) +0.0025%

@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.

Reviewed — changes requested

Changes are required before merge: make allocation failure in MakeNumpunctString throw std::bad_alloc before copying.

What I ran

Reviewed head 913524c1eec677eae00513422614a0d8cee8ba5a using the prepared diff and pinned reader; no build or tests were run. The author reports a successful build and tests in description.md.

Results

Check Result Note
Changed source review failed Allocation failure can reach memcpy as a null pointer.
Build and tests not run Author-reported results only.

Findings

Blocking

  • core/libs/prx/libc/src/LocaleSupport.cpp:1559 — MakeNumpunctString calls the throwing operator new[] wrapper, but that wrapper delegates to Allocate, which returns the application heap result directly. If the heap API returns null without throwing, the next memcpy dereferences null. _Init's catch-and-cleanup path therefore does not handle this failure, despite the stated bad_alloc behavior and the new test expecting it. Check the returned pointer and throw std::bad_alloc before copying, or ensure the allocation wrapper translates null to an exception.

Non-blocking

None.

Sources

  • The helper and _Init cleanup path are in core/libs/prx/libc/src/LocaleSupport.cpp:1557 and core/libs/prx/libc/src/LocaleSupport.cpp:1584.
  • operator new[] delegates to Allocate in core/libs/prx/libc/src/StdioExtras.cpp:110; Allocate directly returns the heap allocation result in core/libs/prx/libc/src/StdioExtras.cpp:25.
  • The new failure test configures a null-returning allocator and expects std::bad_alloc in core/libs/tests/GuestNumpunctFacet.cpp:34 and core/libs/tests/GuestNumpunctFacet.cpp:385.

Not verified

No commands, build, or tests were run. I read all seven changed files listed in the manifest; no files were excluded by the manifest.

To get this to a good state

Make MakeNumpunctString convert a null allocation result to std::bad_alloc, then rerun guest_numpunct_facet and the reported build and convention checks on the updated head.

@github-actions

github-actions Bot commented Nov 16, 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 7447 core/libs/prx/libc/CMakeLists.txt
PR 7715 core/libs/prx/libc/CMakeLists.txt
PR 8150 core/libs/prx/libc/CMakeLists.txt
PR 8965 core/libs/prx/libc/CMakeLists.txt
PR 11172 core/libs/prx/libc/src/LocaleSupport.cpp
core/libs/tests/GuestLocale.cpp
PR 12682 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
PR 12688 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
PR 12700 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
PR 12717 core/libs/prx/libc/CMakeLists.txt
PR 12849 core/libs/prx/libc/CMakeLists.txt
PR 12965 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/include/Api.hpp
PR 16791 core/libs/prx/libc/CMakeLists.txt
PR 17557 core/libs/prx/libc/CMakeLists.txt
PR 17746 core/libs/prx/libc/include/GuestLocale.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 18135 core/libs/prx/libc/include/Api.hpp
core/libs/prx/libc/include/GuestLocale.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 18190 core/libs/prx/libc/include/Api.hpp
PR 19181 core/libs/prx/libc/CMakeLists.txt
PR 23395 core/libs/prx/libc/CMakeLists.txt
PR 24322 core/libs/prx/libc/CMakeLists.txt
PR 24910 core/libs/prx/libc/CMakeLists.txt
PR 24917 core/libs/prx/libc/CMakeLists.txt
PR 25573 core/libs/prx/libc/include/GuestLocale.hpp
core/libs/prx/libc/src/LocaleSupport.cpp
PR 26796 core/libs/prx/libc/CMakeLists.txt

MakeNumpunctString now throws std::bad_alloc when operator new[]
returns null, before memcpy, as review requested. operator new[]
already throws there: ApplicationHeapAllocate_nid_no_patch passes the
heap callback's result through requireAllocation (ApplicationHeap.cpp
lines 106-109), so behaviour does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Herolias

Copy link
Copy Markdown
Contributor Author

@MarcZX10 2ba615a adds the check: MakeNumpunctString now throws std::bad_alloc when operator new[] returns null, before memcpy.

Behaviour does not change. ApplicationHeapAllocate_nid_no_patch already turns a null heap result into std::bad_alloc (ApplicationHeap.cpp lines 106-109 and 212-216). That is why CheckInitFailure, whose heap returns null on each allocation in turn, passed before this commit too. No test reaches the new line.

Checked on this head (Fedora 44, GCC 16.2.1):

  • the full build;
  • tools/select_tests.py ctest: 5775 of 5776 pass, including guest_numpunct_facet, guest_locale, public_headers and patched_self_imports. The one failure, agc_driver_image_table_packed_guards, comes from main, as the description says;
  • tools/check_conventions.py --base origin/main;
  • tools/pr_overlap.py --branch feat/numpunct-char-facet: the 23 PRs it reports have the same conflict hunks against main as against this branch.

@PrivacyOnion PrivacyOnion 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.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 2ba615ab6c:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_locale_tests, guest_numpunct_facet_tests built cleanly.
  • CTest (guest_locale, guest_numpunct_facet):
    1/2 Test #1344: guest_numpunct_facet .............   Passed    0.00 sec
    2/2 Test #1343: guest_locale .....................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/include/GuestLocale.hpp, core/libs/prx/libc/src/LocaleSupport.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified _ZTVSt8numpunctIcE_nid_postfix vtable layout in core/libs/prx/libc/src/LocaleSupport.cpp:816-828: slots 0-1 are zero (offset-to-top, RTTI), slots 2-10 correctly map destroy, deleteObject, retain, release, and five do_* methods matching Dinkumware / libc ABI order.
    • Audited dynamic memory handling in MakeNumpunctString and NumpunctInit_nid_no_patch (LocaleSupport.cpp:1556-1598): verified exception safety, std::bad_alloc check on null allocation, and proper cleanup via NumpunctTidy_nid_no_patch in the catch handler.
    • Verified null pointer checks across all newly added constructor, destructor, _Init, and _Tidy exports in LocaleSupport.cpp:1571-1632: each properly guards self == nullptr with APS5_INVALID_ARG_EX.
    • Verified reference count truncation and initialization in ConstructNumpunctBase and constructors (LocaleSupport.cpp:1564-1622): references is properly initialized as uint32_t and vtable points to _ZTVSt8numpunctIcE_nid_postfix[2].
    • Audited docs/dev/debt/changes/feat-numpunct-char-facet.md and test coverage in GuestNumpunctFacet.cpp and GuestLocale.cpp, confirming AGENTS.md rules compliance, absence of forbidden code comments, and full heap failure / argument validation tests.

Looks Good To Me

@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.

Reviewed — no blocking findings

The inspected implementation and tests show no verified blocking defect; the reported build and test results were not independently run in this review.

What I ran

Read the prepared diff and review metadata for head 2ba615ab6c64b7ee46e1feb265ff45ff73a00e03, then inspected the changed implementation, declarations, and test code through repo_read.py. No build or tests were run.

Results

Check Result Note
Diff and targeted source review passed No blocking defect verified
Build and tests not run Results in the PR description are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests were run independently. The review folder lists seven changed files, all included. Read: core/libs/prx/libc/CMakeLists.txt, core/libs/prx/libc/include/GuestLocale.hpp, core/libs/prx/libc/src/LocaleSupport.cpp, and the prepared diff for core/libs/prx/libc/include/Api.hpp, core/libs/tests/GuestLocale.cpp, core/libs/tests/GuestNumpunctFacet.cpp, and docs/dev/debt/changes/feat-numpunct-char-facet.md. The full text of every changed file was not read. No files were excluded by the manifest.

To get this to a good state

Nothing is required. The build and test results reported in the description remain unverified here.

@Helldiverr

Copy link
Copy Markdown
Contributor

Works on Windows and nothing blocks. Merged onto current main, all 7 locale tests pass in 3 of 3 runs (6 of 6 on main alone). Every one of the 11 new exports and the vtable is in the Windows libc.prx export table. The negative control and all 10 mutations fail at least one test.

Existing runs: the author, Herolias, tested on Fedora Linux only and wrote that nothing ran on Windows. PrivacyOnion approved 913524c1ee and 2ba615ab6c after a Linux run. MarcZX10 requested changes at 913524c1ee for the unchecked allocation. Their later review at 2ba615ab6c is a comment with no blocking findings, from a code read with no build or tests. The CI windows job passed at 2ba615ab6c (run 43986243995, started 2026-11-17), merged onto the main of that day and limited to the changed tests. No reviewer has posted a Windows run.

What this run adds

  • The merge onto main f4c9a67f58, with the 7 tests that cover numpunct<char> and the code around it, run 3 times with WinLibs GCC. main has since moved to 22fbb84971. Its 2 new commits touch neither core/libs/prx/libc nor GuestLocale.cpp, and the PR still merges cleanly onto it.
  • A check of the export table of the merged build/tests/libc.prx with objdump -p. Each of these names appears once:
    • the 7 _ZNSt8numpunctIcE..._nid_postfix members (_Init, _Tidy, C1Em, C2Em, C1ERKSt8_Locinfomb, C2EPKcmb, D1Ev);
    • Cb1hI+w9nyU, WK24j1F3rCU, xFva4yxsVW8 and Lf6h5krl2fA as <nid>_nid_no_patch_cut;
    • _ZTVSt8numpunctIcE_nid_postfix.
  • A recomputation of all 12 NIDs in the debt fragment with tools/nid_names.compute_nid. All 12 match.
  • A negative control and 10 mutations of LocaleSupport.cpp, listed below.

Code

  1. The vtable at core/libs/prx/libc/src/LocaleSupport.cpp:816-828 (2ba615ab6c) now points slots 2 and 3 at the new NumpunctDestroy/NumpunctDelete. The facet that _Getcat builds (:1448-1452) still uses the internal g_numpunctVtable (:337), with DestroyCollate and static strings. The debt fragment states this, so a facet from _Getcat and one from the new constructors free their strings differently. That is consistent, because only the constructors allocate.
  2. NumpunctInit_nid_no_patch (:1579-1599) leaves its _Locinfo parameter unnamed and reads the global localeconv_nid_postfix() (:1581). Dinkumware reads the lconv through _Locinfo. On today's main the result is the same: _Locinfo accepts only "C" (LocaleSupport.cpp:2330-2333 at f4c9a67f58), and so does setlocale (StdioExtras.cpp:89-94). Once a second locale exists, _Init would follow the global locale instead of the _Locinfo it was given. The fragment describes the behaviour as copying localeconv(), so this is already recorded. It does not block.
  3. The bad_alloc check in MakeNumpunctString (:1560), added for MarcZX10's review, cannot fire. _Znam_nid_postfix calls Allocate (StdioExtras.cpp:110-112 at f4c9a67f58), and Allocate calls ApplicationHeapAllocate_nid_no_patch, which throws on null (ApplicationHeap.cpp:111-113, 220-223). Herolias said the same in the thread. The line is harmless.
  4. In guest_numpunct_facet, nothing checks which do_* function sits in which vtable slot. Swapping the do_falsename and do_truename slots passes that test. guest_locale (CheckNumpunctVtableObject) catches the swap, so it is covered across the two tests.
  5. Clearing a stale truename before allocating is covered, but only through a heap fault. Without the reset, the failure path frees the string literal "stale", and the test dies with 0xc0000374 (heap corruption) rather than at a Require line.
  6. check_conventions.py --base f4c9a67f58 passes, and debt_fold.py --check passes with no output.

Negative control and mutation

Line numbers are at 2ba615ab6c. "facet" is guest_numpunct_facet and "locale" is guest_locale. Every other test passed in every row.

Change to LocaleSupport.cpp facet locale
Negative control: slots 2-10 of _ZTVSt8numpunctIcE zeroed, as on main (:819-827) fails (segfault) fails
do_falsename and do_truename slots swapped (:826-827) passes fails
Slot 2 set to DestroyCollate (:819) fails at :206 fails
_Tidy no longer frees truename (:1576) fails at :114 passes
_Init no longer clears truename first (:1584) fails (0xc0000374) passes
_Init swallows the allocation failure (:1591) fails at :69 passes
_Init does not run _Tidy on failure (:1590) fails at :131 passes
isDefault ignored, always ./, (:1593) fails at :110 passes
size_t constructor no longer replaces a zero separator with , (:1607) fails at :154 fails
Reference count not stored (:1567) fails at :151 fails
Deleting destructor skips operator delete (:1632) fails at :218 passes

Tests

Test main merge run 1 merge run 2 merge run 3
guest_numpunct_facet not on main 0.03 0.01 0.02
guest_locale 0.04 0.04 0.01 0.02
guest_collate 0.04 0.03 0.01 0.01
guest_sce_v2_locale 0.07 0.05 0.01 0.01
guest_sce_v2_makeloc 0.06 0.04 0.01 0.02
guest_libc_internal_numpunct 0.05 0.06 0.03 0.03
guest_ctype_case 0.06 0.06 0.03 0.03

Times are in seconds. All runs pass.

Host

  • CPU: Ryzen 9 9950X3D
  • OS: Windows 11 Pro 26300
  • Toolchain: WinLibs GCC 15.2, Release
  • Commits: head 2ba615ab6c, merged onto main f4c9a67f58 as 2b21b53ca8

AI-assisted: yes

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 25, 2026
# Conflicts:
#	core/libs/prx/libc/CMakeLists.txt

@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.

Reviewed — looks good

Nothing blocks this change; the checks reported for the exact head support merging, and the source review found no verified blocking defect.

What I ran

Reviewed head caf99e04ab9ff1499882e4fd81089a68dd660408 using repo_read.py. No build or tests were run during this review; test results below are author-reported.

Results

Check Result Note
Source review passed Changed implementation and test diff inspected
Build and tests not run Results supplied in PR description
Negative control not run Not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

Did not independently run the build, tests, convention checks, or negative controls, and did not inspect console behavior. Reviewed all seven files listed in manifest.json under reviewed; none were excluded by rule. Full changed-file texts were not available in the prepared review folder; inspected the relevant implementation range through repo_read.py and the changed lines in diff.patch. Other unchanged callers and contexts were not read.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 25, 2026
@oneandonlydean
oneandonlydean merged commit 397655d into boykopovar:main Nov 26, 2026
22 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.

5 participants