feat(libSceFreeType): implement the legacy reallocation helpers #12373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12373"
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 santhoshkumar-dev on 2026-10-28T11:46:44Z.
What
Add the legacy reallocation family
FT_Realloc(HVSaZbxYi2s) andFT_QRealloc(KVbmKCGGowg) to the physicallibSceFreeTypeadapter, completing the allocator family from #12004. Both take the guestGuestMemoryRec, a current size, a new size and a guest in-out block pointer. The names/NIDs are in the PS5 3.20 inventory and re-derive from the repository's own NID hash; open/closed/merged history has no other implementation.The contract follows
ft_mem_qreallocwith unit item size in FreeType 2.4.12: negative current or new size reportInvalid_Argumentand keep the guest output; a zero new size releases the block through the free callback and clears the output; sizes aboveINT_MAXreportArray_Too_Largeand keep the output; an empty current takes the zeroing allocation path (the reference's fresh path uses the zeroing allocator for both variants); a growth callback that returns null reportsOut_Of_Memorywhile keeping the previous block in the output; and onlyFT_Reallocadditionally clears the grown region. Null records or outputs make the helpers throw; the reference implementation dereferences them. Console ABI is unverified and recorded in debt.The matching OT inventory helpers are named
sceFreeTypeOtRealloc_nid_no_patchandsceFreeTypeOtQRealloc_nid_no_patchand declared once inlibSceFreeTypeOt/include/MemoryAllocation.hpp, reachable through the Ot umbrella included by the export implementation; their no-parameter placeholders, explicit NID aliases and throwing behavior remain.Ordering: Depends on: #12004. This branch now includes that PR's reviewed allocator fixes at
6b7a1c9446fb4baa14531190e0b62e0e273ad116. After #12004 lands, this PR will be refreshed to retain only the reallocation follow-up. Submitted head94b05e61d0b834554672e1ddf061c41e4fecca89merges cleanly with current mainaaccd0ba39b7d40fdbf19664575a7e567d8542f7. The Ot allocator declarations are separated from the shared FreeType header, and the allocator/debt additions use distinct anchors from the other pending FreeType contributions. The acceptance side of theINT_MAXboundary (a 2 GiB allocation) is not exercised to keep CI bounded; the rejection side is covered.Tested
Current submitted head
94b05e61d0b834554672e1ddf061c41e4fecca89carries the allocator review corrections without changing the allocation/reallocation implementation from previously tested head22dfb9f66b56dbb6d6b8c95f07232758f335d1db. The 70/70 full-library/focused-CTest results below refer to that earlier head, based on #12004 head74276c4683and mainc02d287bd0; they were not rerun as a full product build for this header/debt/test-only follow-up.Fresh October 29 checks on Windows 11 / WinLibs GCC 15.2.0 and Ubuntu under WSL / GCC 13.3.0: the public-header audit passes (368 libraries, 13,056 exports), the canonical public headers compile independently and together, and the Ot export translation unit compiles. Each platform freshly compiles production
MemoryAllocation.cppand the revised in-tree fixture as isolated artifacts, then passes three runs in each normal and repository-NID-patched export mode. The fixture retains all allocation/reallocation cases and adds null-record/null-outputFT_Freecalls that preserve a live block, contents and callback counts until normal release. Windows uses the existing product libc import library/binaries for custom unwind support. This is not a fresh completelibsbuild. Conventions and whitespace pass.Windows 11 x64 / WinLibs GCC 15.2.0 r7 and local Ubuntu 24.04.1 x86-64 under WSL2 / GCC 13.3.0 / glibc 2.39: Ninja Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=OFF, in fresh build trees on each platform. On each platform the completelibstarget (including all packaged-NID.prxpatching) and selected test executables build, and 70/70 CTests pass: public-header audit, all 64 header compilation batches, the allocator fixture's both export modes (unpatched names and packaged NIDsUw+BZJpflxk/hz-J3hohXW8/fHMsRluEMfI/HVSaZbxYi2s/KVbmKCGGowg), charmap checks and the packaged-library loader.The fixture registers counting guest callbacks with a deterministic realloc (preserves the prefix, fills growth with a marker). Each mode verifies, for both helpers: the fresh path returning zeroed contents; growth preserving a written prefix while
FT_Reallocclears the grown region andFT_QReallocleaves the callback's marker there;-1,INT64_MINcurrent and size, and size2147483648producingInvalid_Argument/Array_Too_Largewith the output pointer kept and zero callback traffic; zero size releasing through the free callback and clearing the output, with a null block producing no release; a failing growth callback producingOut_Of_Memorywith the previous block kept and no free; and a failing fresh allocation producingOut_Of_Memorywith a cleared output.No full application/test-suite, macOS, title or physical-console run is claimed.
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-28T11:54:47Z.
Review: COMMENTED
Reviewed exact head
22dfb9f66b56dbb6d6b8c95f07232758f335d1db. I comparedReallocateagainst the linked FreeType 2.4.12ft_mem_qrealloccontract: invalid negative sizes and over-INT_MAXrequests leave the output pointer untouched; zero size frees and clears it; a fresh allocation uses the zeroed allocation path; failed growth preserves the original pointer; and onlyFT_Realloczeroes the grown tail. I builtMemoryAllocation.cppandGuestFreeTypeMemoryAllocation.cppdirectly with GCC on this Linux host and ran the unpatched-symbol fixture successfully.git diff --checkandtools/check_conventions.py --base upstream/mainalso pass. The hosted Windows check is still in progress, so I have not approved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T12:08:53Z.
Review: APPROVED
The exact-head review and focused allocator fixture support the documented FreeType 2.4.12 behavior, and the Windows CI check has now passed. I found no remaining correctness issue in the reviewed change.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:43:32Z.
Review: APPROVED
Re-reviewed exact head
94b05e61d0b834554672e1ddf061c41e4fecca89. Relative to the previously reviewed head22dfb9f66b, production allocator/reallocator source is unchanged. The follow-up moves the three Ot placeholder declarations into their library-specific header and addsFT_Freenull-input coverage that verifies the block and free/allocation counters remain unchanged until a valid release. The author reports cross-platform standalone/header builds and the allocation/reallocation fixture passing three times on Windows and Ubuntu WSL, plus a clean current-main merge/conventions check. The PR keepsDepends on: #12004; it remains stacked on that open prerequisite. I inspected the new diff andgit diff --check; I did not rerun the author’s builds or tests locally. Hosted checks for the new head are still queued.