feat(libfontconfig): match firmware configuration export behavior #15294

Merged
hyvvs merged 9 commits from upstream-pr/15294 into main 2026-11-07 10:18:41 +00:00
hyvvs commented 2026-11-02 22:53:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-11-02T22:53:23Z.


What

Match the three libfontconfig configuration exports to the inspected firmware 13.42 module rather than desktop Fontconfig behavior: FcConfigCreate() returns null, FcConfigReference(config) returns null for both null and nonnull arguments, and FcConfigDestroy(config) is a no-op for both. The public calls retain typed APS5_VABI signatures and are documented as firmware-observed silent stubs, not fabricated success values.

Reviewer BunnyFl provided the complete short disassemblies in the review, from system_ex/common_ex/lib/libfontconfig.sprx SHA-256 74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472: creation and reference each clear eax and return; destroy returns without touching its argument. This is firmware disassembly, not console execution, and behavior on other firmware is not established. The previous host Fontconfig reference-counted objects and null-reference throw were incompatible with this evidence; they have been removed. The change does not implement font discovery, rule substitution or configuration loading.

The focused test source-links Config.cpp, keeps Release assertions enabled, checks both null and nonnull reference/destroy inputs and unchanged caller storage, and uses configure_host_test_executable as requested in review. The production PRX retains its own Windows unwind configuration. Silent-stub scope and firmware limitations are described in docs/dev/debt/libfontconfig.md. Independent of #15283 at the function level; it shares the module's CMakeLists.txt and debt file and could need textual merge resolution.

Tested

  • Windows MinGW GCC 15.2 -O3 -DNDEBUG -Wall -Wextra -Werror -pedantic -fasynchronous-unwind-tables -static -static-libgcc -static-libstdc++: focused GuestFontconfigConfig.cpp + Config.cpp built and executed, exit 0; 256 repeated cycles of all three firmware-return contracts, including a nonnull pointer without dereference.
  • Ubuntu WSL GCC with ASan+UBSan and ASAN_OPTIONS=detect_leaks=1:halt_on_error=1: focused test passed.
  • Negative control: the same test against the still-throwing base upstream/main Export.cpp aborted on its first unsupported export as expected; it does not pass simply because assertions were disabled.
  • Strict repository convention checker, changed-tree whitespace check and hosted Windows CTest: see checks on this PR (hosted outcome not claimed before completion).

Not tested: physical PS5 firmware execution, cross-firmware equivalence, full integrated library CTest in local worktree, or Mac. No new third-party code.

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 (no new third-party code)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5128724526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15294). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-11-02T22:53:23Z. --- ### What Match the three `libfontconfig` configuration exports to the inspected firmware 13.42 module rather than desktop Fontconfig behavior: `FcConfigCreate()` returns null, `FcConfigReference(config)` returns null for both null and nonnull arguments, and `FcConfigDestroy(config)` is a no-op for both. The public calls retain typed `APS5_VABI` signatures and are documented as **firmware-observed silent stubs**, not fabricated success values. Reviewer BunnyFl provided the complete short disassemblies in [the review](https://github.com/boykopovar/AnyPS5/pull/15294), from `system_ex/common_ex/lib/libfontconfig.sprx` SHA-256 `74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472`: creation and reference each clear `eax` and return; destroy returns without touching its argument. **This is firmware disassembly, not console execution**, and behavior on other firmware is not established. The previous host Fontconfig reference-counted objects and null-reference throw were incompatible with this evidence; they have been removed. The change does not implement font discovery, rule substitution or configuration loading. The focused test source-links `Config.cpp`, keeps Release assertions enabled, checks both null and nonnull reference/destroy inputs and unchanged caller storage, and uses `configure_host_test_executable` as requested in review. The production PRX retains its own Windows unwind configuration. Silent-stub scope and firmware limitations are described in `docs/dev/debt/libfontconfig.md`. Independent of #15283 at the function level; it shares the module's `CMakeLists.txt` and debt file and could need textual merge resolution. ### Tested - Windows MinGW GCC 15.2 `-O3 -DNDEBUG -Wall -Wextra -Werror -pedantic -fasynchronous-unwind-tables -static -static-libgcc -static-libstdc++`: focused `GuestFontconfigConfig.cpp` + `Config.cpp` built and executed, exit 0; 256 repeated cycles of all three firmware-return contracts, including a nonnull pointer without dereference. - Ubuntu WSL GCC with ASan+UBSan and `ASAN_OPTIONS=detect_leaks=1:halt_on_error=1`: focused test passed. - Negative control: the same test against the still-throwing base `upstream/main` `Export.cpp` aborted on its first unsupported export as expected; it does not pass simply because assertions were disabled. - Strict repository convention checker, changed-tree whitespace check and hosted Windows CTest: see checks on this PR (hosted outcome not claimed before completion). Not tested: physical PS5 firmware execution, cross-firmware equivalence, full integrated library CTest in local worktree, or Mac. No new third-party code. ### Checklist - [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 (no new third-party code) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-03 02:57:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T02:57:57Z.

Review: CHANGES_REQUESTED


The PR follows Fontconfig 2.15.0, but the console's module behaves differently. In firmware 13.42's system_ex/common_ex/lib/libfontconfig.sprx (sha256 74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472), all three of these exports are stubs. Each body below is read to its return, disassembly only, not measured on a console:

FcConfigCreate     (HGtDYp4ddNE)
 100: 31 c0     xor    %eax,%eax
 102: c3        ret
FcConfigDestroy    (Oor7ukCXZOE)
 110: c3        ret
FcConfigReference  (yQed09jA3VA)
 120: 31 c0     xor    %eax,%eax
 122: c3        ret

So on the console:

  • FcConfigCreate returns NULL.
  • FcConfigReference returns NULL for any argument, including NULL. It does not dereference it.
  • FcConfigDestroy does nothing for any argument.

The neighbouring FcConfigGetCurrent (0x130) is the same xor %eax,%eax; ret, so the module has no configuration objects at all.

With this PR, a title that checks FcConfigCreate() == NULL gets a live handle instead. FcConfigReference(NULL) throws, where the console returns NULL. Could you implement the three as the module does (return NULL, return NULL, no-op), with a test that uses main as its negative control? Please record in docs/dev/debt/libfontconfig.md that this follows the 13.42 disassembly and isn't measured on a console. The reference-counting code and its concurrency test would then go away.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5746715507 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15294#pullrequestreview-5746715507). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T02:57:57Z. **Review:** CHANGES_REQUESTED --- The PR follows Fontconfig 2.15.0, but the console's module behaves differently. In firmware 13.42's `system_ex/common_ex/lib/libfontconfig.sprx` (sha256 `74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472`), all three of these exports are stubs. Each body below is read to its return, disassembly only, not measured on a console: ``` FcConfigCreate (HGtDYp4ddNE) 100: 31 c0 xor %eax,%eax 102: c3 ret FcConfigDestroy (Oor7ukCXZOE) 110: c3 ret FcConfigReference (yQed09jA3VA) 120: 31 c0 xor %eax,%eax 122: c3 ret ``` So on the console: - `FcConfigCreate` returns NULL. - `FcConfigReference` returns NULL for any argument, including NULL. It does not dereference it. - `FcConfigDestroy` does nothing for any argument. The neighbouring `FcConfigGetCurrent` (`0x130`) is the same `xor %eax,%eax; ret`, so the module has no configuration objects at all. With this PR, a title that checks `FcConfigCreate() == NULL` gets a live handle instead. `FcConfigReference(NULL)` throws, where the console returns NULL. Could you implement the three as the module does (return NULL, return NULL, no-op), with a test that uses `main` as its negative control? Please record in `docs/dev/debt/libfontconfig.md` that this follows the 13.42 disassembly and isn't measured on a console. The reference-counting code and its concurrency test would then go away.
BunnyFl commented 2026-11-03 13:43:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T13:43:46Z.

Review: APPROVED


Re-checked — approved

@hyvvs thanks. FcConfigCreate and FcConfigReference now return NULL for every argument, and FcConfigDestroy does nothing. That matches the 13.42 bodies I posted. The debt entry also says this comes from the disassembly and was not measured on a console.

On Windows (WinLibs GCC), with head fa5b2d281d merged into main, guest_fontconfig_config passes. main has no Config.cpp to swap back in, so I broke the code instead. The test fails both when FcConfigCreate returns a non-NULL pointer and when FcConfigDestroy writes through its argument.

Non-blocking:

  • core/libs/prx/libfontconfig/CMakeLists.txt keeps -fasynchronous-unwind-tables and target_link_libraries(libfontconfig PRIVATE libc) from the reference-counting version. Nothing in Config.cpp throws any more, and the loop in core/libs/CMakeLists.txt already links libc to every library, so both lines could go.
  • My #15363 touches the same files: libfontconfig.hpp, the debt file, and its own struct FcConfig; declaration. It answers FcConfigGetCurrent (NULL) and FcInitBringUptoDate (1). Whichever lands second needs a small rebase, and the debt sentence "FcConfigGetCurrent ... still throw" would then need updating.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5753195721 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15294#pullrequestreview-5753195721). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T13:43:46Z. **Review:** APPROVED --- # Re-checked — approved @hyvvs thanks. `FcConfigCreate` and `FcConfigReference` now return NULL for every argument, and `FcConfigDestroy` does nothing. That matches the 13.42 bodies I posted. The debt entry also says this comes from the disassembly and was not measured on a console. On Windows (WinLibs GCC), with head `fa5b2d281d` merged into `main`, `guest_fontconfig_config` passes. `main` has no `Config.cpp` to swap back in, so I broke the code instead. The test fails both when `FcConfigCreate` returns a non-NULL pointer and when `FcConfigDestroy` writes through its argument. Non-blocking: - `core/libs/prx/libfontconfig/CMakeLists.txt` keeps `-fasynchronous-unwind-tables` and `target_link_libraries(libfontconfig PRIVATE libc)` from the reference-counting version. Nothing in `Config.cpp` throws any more, and the loop in `core/libs/CMakeLists.txt` already links `libc` to every library, so both lines could go. - My #15363 touches the same files: `libfontconfig.hpp`, the debt file, and its own `struct FcConfig;` declaration. It answers `FcConfigGetCurrent` (NULL) and `FcInitBringUptoDate` (1). Whichever lands second needs a small rebase, and the debt sentence "`FcConfigGetCurrent` ... still throw" would then need updating.
adriadam10 commented 2026-11-07 03:48:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-07T03:48:17Z.

Review: CHANGES_REQUESTED


The firmware-13.42 behaviour (null create/reference, no-op destroy) matches the disassembly BunnyFl posted, and the test pins it, but the hosted Windows build fails on this head:

  • core/libs/prx/libfontconfig/CMakeLists.txt:6-7: the if(MINGW) target_compile_options(libfontconfig PRIVATE -fasynchronous-unwind-tables) block breaks Export.cpp. The compile line then carries -fno-asynchronous-unwind-tables -fasynchronous-unwind-tables, and the assembler rejects it: Error: .seh_handlerdata used outside of .seh_proc block (Build run 42308148378, job windows, libfontconfig.dir/Export.cpp.obj). The flag was added for the earlier exception-based Config.cpp; Config.cpp no longer throws, and configure_windows_unwind(libfontconfig) on the line above already handles the unwind setup. Please drop the block and check that the Windows job goes green.

Everything else I checked is fine (typed signatures, debt entry under Silent stubs, test pins null returns and unchanged storage for null and nonnull inputs).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5809884702 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15294#pullrequestreview-5809884702). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-07T03:48:17Z. **Review:** CHANGES_REQUESTED --- The firmware-13.42 behaviour (null create/reference, no-op destroy) matches the disassembly BunnyFl posted, and the test pins it, but the hosted Windows build fails on this head: - `core/libs/prx/libfontconfig/CMakeLists.txt:6-7`: the `if(MINGW) target_compile_options(libfontconfig PRIVATE -fasynchronous-unwind-tables)` block breaks `Export.cpp`. The compile line then carries `-fno-asynchronous-unwind-tables -fasynchronous-unwind-tables`, and the assembler rejects it: `Error: .seh_handlerdata used outside of .seh_proc block` (Build run 42308148378, job `windows`, `libfontconfig.dir/Export.cpp.obj`). The flag was added for the earlier exception-based `Config.cpp`; `Config.cpp` no longer throws, and `configure_windows_unwind(libfontconfig)` on the line above already handles the unwind setup. Please drop the block and check that the Windows job goes green. Everything else I checked is fine (typed signatures, debt entry under Silent stubs, test pins null returns and unchanged storage for null and nonnull inputs).
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!15294
No description provided.