feat(libSceFreeTypeOt): implement the 2.4.11 outline and memory record calls #15865

Merged
KernelPanicNT merged 2 commits from upstream-pr/15865 into main 2026-11-08 12:33:11 +00:00
KernelPanicNT commented 2026-11-04 20:29:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-11-04T20:29:05Z.


What

Implements three libSceFreeTypeOt exports that called NotImplemented_nid_no_patch. They follow FreeType 2.4.11, the version libSceFreeTypeOt reports:

  • FT_Outline_New_Internal (NG7OgYsgcF8) and FT_Outline_Done_Internal (umIqupy8UU0), in a new src/Outline.cpp. They allocate and free through the caller's memory record with the existing ft_mem_realloc / ft_mem_free of src/Memory.cpp, as 2.4.11 FT_NEW_ARRAY / FT_FREE do.
  • FT_New_Memory (tCMhTh7h8D4). libSceFreeTypeOt now builds the libSceFreeType/src/MemoryRecord.cpp that libSceFreeType already exports with this NID, the same way it already builds OutlineBorders.cpp and Trigonometry.cpp. 2.4.11 ftsystem.c (both the src/base and the builds/unix copy) creates the record with malloc, sets user to 0 and installs malloc / realloc / free callbacks. MemoryRecord.cpp does the same. Because the file is shared, libSceFreeTypeOt also exports FT_Done_Memory, which its export list does not have; the debt entry says so.
  • Removes the sceFreeTypeOtNewMemory_nid_no_patch declaration from MemoryRecord.hpp. It belonged to the removed stub.
  • Debt: a new libSceFreeTypeOt entry for the gaps that are still open. The entry added by #11613 said the provider's version is unmeasured; it now points to the measured 2.4.11, and its 2.4.12 link uses a short SHA.

Not in this PR: libSceFreeTypeOl FT_Done_Memory (UTumVjeIQtg). Its debt entry says the export has no parameter and works on a Sony-owned global memory manager, and the 2.4.11 sources disagree with each other on it (src/base/ftsystem.c calls free(memory), builds/unix/ftsystem.c calls memory->free(memory, memory)), so it keeps throwing. FT_Sin, FT_Tan and FT_Vector_Unit were implemented by #11613. The libSceFreeTypeOt debt line that counts the sceFreeTypeOtUnknown_* stubs still says 68; this PR removes two of them (66), and #15687 rewrites that line to 60 for its own renames, so whichever lands second updates the number.

Source of the behaviour

Case Device FreeType 2.4.11 source AnyPS5 now
Library version FT_Library_Version returned 2.4.11 when measured as a payload process on a device (firmware 13.00) - outline and memory calls follow 2.4.11
FT_Outline_New_Internal, null memory or outline not measured Invalid_Argument (6), nothing written same
New, valid counts not measured outline cleared, then points (16 B each), tags (1 B), contours (2 B) through ft_mem_realloc, cleared; counts stored as 16-bit; only FT_OUTLINE_OWNER set same
New, negative contour count not measured no up-front check (2.4.12 added one): points and tags allocated, contours fail with Invalid_Argument, both freed, outline cleared same
New, array above FT_INT_MAX bytes (points from 0x08000000, contours from 0x40000000) not measured Array_Too_Large (0x0A), earlier arrays freed same
New, allocator returns null not measured Out_Of_Memory (0x40), earlier arrays freed same
New, counts above 0xFFFF not measured arrays sized from the full count, stored count keeps the low 16 bits same
FT_Outline_Done_Internal not measured null memory or outline: Invalid_Argument; otherwise frees points, tags, contours only if FT_OUTLINE_OWNER is set, then clears the outline same
FT_New_Memory not measured malloc record, user 0, C allocator callbacks same (shared MemoryRecord.cpp)

Tested

Linux x86-64 (Ubuntu, GCC), on main 9ab6a281ea. The new guest_freetype_ot_outline test loads libSceFreeTypeOt and resolves the three calls and FT_Done_Memory by name (raw) and by NID (_patched). It checks the null-argument errors, the allocation order and sizes (16/1/2 bytes per item), cleared arrays, the stored 16-bit counts (70000 points, 0x12345 contours, 40000 points) and the flags. It also checks Invalid_Argument for a negative contour count after points and tags are freed, Array_Too_Large at 0x08000000 and 0xFFFFFFFF points and 0x40000000 contours, the 0x7FFFFFF0-byte boundary reaching the allocator, Out_Of_Memory on the second and third allocation, FT_Outline_Done_Internal freeing only owned outlines and skipping null arrays, and an outline built and released on a FT_New_Memory record. The same test binary also passes against FreeType 2.4.11 itself: ftoutln.c, ftutil.c and src/base/ftsystem.c from c6a66b49e64e compiled into a shared object with the _nid_postfix names forwarding to them, so the expectations are the 2.4.11 behaviour and not just this implementation. ctest -R 'guest_freetype_ot|guest_freetype_corner|guest_freetype_memory_record|public_headers': 73 of 73 passed, including #11613's guest_freetype_ot raw and patched. Negative control: with Export.cpp and MemoryRecord.hpp from main and Outline.cpp/MemoryRecord.cpp out of the build, both new tests fail; with only the two outline stubs back and Outline.cpp out, both fail too. tools/progress.py --compare: +2 implemented, 3 throwing stubs removed (libSceFreeTypeOt 49/142 -> 51/141); FT_New_Memory counts under libSceFreeType, which owns the shared source. tools/check_conventions.py --base origin/main passes. Not tested on a device.

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 (textual overlap with #15687 in libSceFreeTypeOt Export.cpp and its debt file; no shared export)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5161122310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15865). Originally posted by [KernelPanicNT](https://github.com/KernelPanicNT) on 2026-11-04T20:29:05Z. --- ### What Implements three libSceFreeTypeOt exports that called `NotImplemented_nid_no_patch`. They follow FreeType 2.4.11, the version libSceFreeTypeOt reports: - `FT_Outline_New_Internal` (`NG7OgYsgcF8`) and `FT_Outline_Done_Internal` (`umIqupy8UU0`), in a new `src/Outline.cpp`. They allocate and free through the caller's memory record with the existing `ft_mem_realloc` / `ft_mem_free` of `src/Memory.cpp`, as 2.4.11 `FT_NEW_ARRAY` / `FT_FREE` do. - `FT_New_Memory` (`tCMhTh7h8D4`). libSceFreeTypeOt now builds the `libSceFreeType/src/MemoryRecord.cpp` that libSceFreeType already exports with this NID, the same way it already builds `OutlineBorders.cpp` and `Trigonometry.cpp`. 2.4.11 `ftsystem.c` (both the `src/base` and the `builds/unix` copy) creates the record with `malloc`, sets `user` to 0 and installs `malloc` / `realloc` / `free` callbacks. `MemoryRecord.cpp` does the same. Because the file is shared, libSceFreeTypeOt also exports `FT_Done_Memory`, which its export list does not have; the debt entry says so. - Removes the `sceFreeTypeOtNewMemory_nid_no_patch` declaration from `MemoryRecord.hpp`. It belonged to the removed stub. - Debt: a new libSceFreeTypeOt entry for the gaps that are still open. The entry added by #11613 said the provider's version is unmeasured; it now points to the measured 2.4.11, and its 2.4.12 link uses a short SHA. Not in this PR: libSceFreeTypeOl `FT_Done_Memory` (`UTumVjeIQtg`). Its debt entry says the export has no parameter and works on a Sony-owned global memory manager, and the 2.4.11 sources disagree with each other on it (`src/base/ftsystem.c` calls `free(memory)`, `builds/unix/ftsystem.c` calls `memory->free(memory, memory)`), so it keeps throwing. `FT_Sin`, `FT_Tan` and `FT_Vector_Unit` were implemented by #11613. The libSceFreeTypeOt debt line that counts the `sceFreeTypeOtUnknown_*` stubs still says 68; this PR removes two of them (66), and #15687 rewrites that line to 60 for its own renames, so whichever lands second updates the number. **Source of the behaviour** | Case | Device | FreeType 2.4.11 source | AnyPS5 now | |---|---|---|---| | Library version | `FT_Library_Version` returned 2.4.11 when measured as a payload process on a device (firmware 13.00) | - | outline and memory calls follow 2.4.11 | | `FT_Outline_New_Internal`, null memory or outline | not measured | `Invalid_Argument` (6), nothing written | same | | New, valid counts | not measured | outline cleared, then points (16 B each), tags (1 B), contours (2 B) through `ft_mem_realloc`, cleared; counts stored as 16-bit; only `FT_OUTLINE_OWNER` set | same | | New, negative contour count | not measured | no up-front check (2.4.12 added one): points and tags allocated, contours fail with `Invalid_Argument`, both freed, outline cleared | same | | New, array above `FT_INT_MAX` bytes (points from `0x08000000`, contours from `0x40000000`) | not measured | `Array_Too_Large` (0x0A), earlier arrays freed | same | | New, allocator returns null | not measured | `Out_Of_Memory` (0x40), earlier arrays freed | same | | New, counts above 0xFFFF | not measured | arrays sized from the full count, stored count keeps the low 16 bits | same | | `FT_Outline_Done_Internal` | not measured | null memory or outline: `Invalid_Argument`; otherwise frees points, tags, contours only if `FT_OUTLINE_OWNER` is set, then clears the outline | same | | `FT_New_Memory` | not measured | `malloc` record, `user` 0, C allocator callbacks | same (shared `MemoryRecord.cpp`) | - FreeType 2.4.11 (`c6a66b49e64e`, the 2.4.11 release commit): [`ftoutln.c#L293-L439`](https://github.com/freetype/freetype/blob/c6a66b49e64e/src/base/ftoutln.c#L293-L439) (`FT_Outline_New_Internal`, `FT_Outline_Done_Internal`), [`ftsystem.c#L286-L304`](https://github.com/freetype/freetype/blob/c6a66b49e64e/src/base/ftsystem.c#L286-L304) (`FT_New_Memory`), [`ftsystem.c#L310-L317`](https://github.com/freetype/freetype/blob/c6a66b49e64e/src/base/ftsystem.c#L310-L317) and [`builds/unix/ftsystem.c#L408-L416`](https://github.com/freetype/freetype/blob/c6a66b49e64e/builds/unix/ftsystem.c#L408-L416) (the two `FT_Done_Memory` bodies that differ), [`ftutil.c#L49-L221`](https://github.com/freetype/freetype/blob/c6a66b49e64e/src/base/ftutil.c#L49-L221) (allocator; 2.4.12's differs only by `FT_THROW`, which yields the same codes). - Removed stubs: [`libSceFreeTypeOt/Export.cpp#L197-L200`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/core/libs/prx/libSceFreeTypeOt/Export.cpp#L197-L200) (`FT_New_Memory`), [`#L227-L230`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/core/libs/prx/libSceFreeTypeOt/Export.cpp#L227-L230) (`umIqupy8UU0`), [`#L257-L260`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/core/libs/prx/libSceFreeTypeOt/Export.cpp#L257-L260) (`NG7OgYsgcF8`), [`MemoryRecord.hpp#L11`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/core/libs/prx/libSceFreeType/include/MemoryRecord.hpp#L11). - Reused code: [`MemoryRecord.cpp#L21-L29`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/core/libs/prx/libSceFreeType/src/MemoryRecord.cpp#L21-L29), [`libSceFreeTypeOt/src/Memory.cpp#L43-L80`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/core/libs/prx/libSceFreeTypeOt/src/Memory.cpp#L43-L80); shared-source precedent: [`libSceFreeTypeOt/CMakeLists.txt#L1-L2`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/core/libs/prx/libSceFreeTypeOt/CMakeLists.txt#L1-L2). - Kept `FT_Done_Memory` debt: [`libSceFreeTypeOl.md#L34`](https://github.com/boykopovar/AnyPS5/blob/9ab6a281ea/docs/dev/debt/libSceFreeTypeOl.md#L34). ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86-64 (Ubuntu, GCC), on `main` `9ab6a281ea`. The new `guest_freetype_ot_outline` test loads libSceFreeTypeOt and resolves the three calls and `FT_Done_Memory` by name (raw) and by NID (`_patched`). It checks the null-argument errors, the allocation order and sizes (16/1/2 bytes per item), cleared arrays, the stored 16-bit counts (70000 points, 0x12345 contours, 40000 points) and the flags. It also checks `Invalid_Argument` for a negative contour count after points and tags are freed, `Array_Too_Large` at `0x08000000` and `0xFFFFFFFF` points and `0x40000000` contours, the `0x7FFFFFF0`-byte boundary reaching the allocator, `Out_Of_Memory` on the second and third allocation, `FT_Outline_Done_Internal` freeing only owned outlines and skipping null arrays, and an outline built and released on a `FT_New_Memory` record. The same test binary also passes against FreeType 2.4.11 itself: `ftoutln.c`, `ftutil.c` and `src/base/ftsystem.c` from `c6a66b49e64e` compiled into a shared object with the `_nid_postfix` names forwarding to them, so the expectations are the 2.4.11 behaviour and not just this implementation. `ctest -R 'guest_freetype_ot|guest_freetype_corner|guest_freetype_memory_record|public_headers'`: 73 of 73 passed, including #11613's `guest_freetype_ot` raw and patched. Negative control: with `Export.cpp` and `MemoryRecord.hpp` from `main` and `Outline.cpp`/`MemoryRecord.cpp` out of the build, both new tests fail; with only the two outline stubs back and `Outline.cpp` out, both fail too. `tools/progress.py --compare`: +2 implemented, 3 throwing stubs removed (libSceFreeTypeOt 49/142 -> 51/141); `FT_New_Memory` counts under libSceFreeType, which owns the shared source. `tools/check_conventions.py --base origin/main` passes. Not tested on a device. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (textual overlap with #15687 in libSceFreeTypeOt `Export.cpp` and its debt file; no shared export) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15865
No description provided.