refactor(libharfbuzz): report guest-input throws as faults #23897

Closed
monika-runtime wants to merge 2 commits from upstream-pr/23897 into main
monika-runtime commented 2026-11-19 21:14:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by monika-runtime on 2026-11-19T21:14:37Z.


What

The seven libharfbuzz exports that still reached NotImplemented_nid_no_patch forward every valid input to the pinned HarfBuzz 10.0.1; their remaining throws guard null handles, unreadable or unwritable guest pointers and buffers, a foreign or finalized FreeType face, a null blob with a nonzero length, an out-of-range memory mode, or a failure to load the bundled ICU data.

This moves the 22 guest-input sites to GuestFault_nid_no_patch and replaces the ICU-data failure with a plain throw std::runtime_error("HarfBuzz ICU NFC data failed to load"): hb_icu_get_unicode_funcs is implemented, and that failure is a host-resource failure, so neither NotImplemented ("not implemented") nor GuestFault ("guest input the console does not define") describes it. tools/progress.py counts both as throws, so libharfbuzz goes from 30 of 37 on current main to 37 of 37.

Sites and their justification, checked against 3rdparty/harfbuzz at the pinned 10.0.1 commit:

  • Export.cpp hb_ft_face_create_cached (6): null face (hb-ft.cc dereferences ft_face->generic/stream), unreadable guest record, a record without a live AnyPS5 FreeType owner (foreign layout), unreadable owner fields or a null/finalized host face (released FT_Face), and the two unwritable generic copies.
  • Shaping.cpp hb_shape (3): null buffer (hb-shape.cc reads buffer->len), null font or a null feature array of nonzero length (null hb_memcpy source in hb-shape-plan.cc), and an unreadable feature array.
  • Lifecycle.cpp hb_blob_create (1): null data with a nonzero length below 2 GiB (stored and later read), and an out-of-range memory mode (out-of-range enum conversion, no upstream behaviour). A length of 2 GiB or more is upstream-rejected and is not faulted.
  • Layout.cpp (12): null faces, unreadable caller counts, a null tag array with a nonzero count, and the host-write bracket and later writes over unwritable count/tag/index buffers. A null count or index is documented as optional and is not faulted.
  • Buffer.cpp (1): the bundled ICU data load, a plain throw as described above.

No control flow changes; the same inputs throw at the same points. No technical-debt entry changes, so no fragment.

This depends on the GuestFault_nid_no_patch helper (#23391); it is part of #23391's per-library migration.

Tested

Linux x86-64, GCC 16.2.1, Release build:

  • cmake --build build --target guest_harfbuzz_tests guest_harfbuzz_buffer_tests guest_harfbuzz_font_tests: builds and links.
  • ctest --test-dir build -R 'harfbuzz': 19 of 19 tests pass.
  • The full Release suite on the same tree: 6,279 of 6,279 tests passed, 0 failed (554.7 s).
  • python3 -I tools/progress.py --module libharfbuzz --json: 37 of 37 (100.0%); current main reports 30 of 37.
  • python3 -I tools/tests/test_progress.py: 81 tests, OK.
  • python3 -I tools/tests/test_progress_wrappers.py: 13 tests, OK.
  • python3 tools/check_conventions.py --base upstream/main: all checks passed.

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: #23849
  • Fixes: none (part of #23391)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Hermes Agent)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5403071994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23897). Originally posted by [monika-runtime](https://github.com/monika-runtime) on 2026-11-19T21:14:37Z. --- ### What The seven libharfbuzz exports that still reached `NotImplemented_nid_no_patch` forward every valid input to the pinned HarfBuzz 10.0.1; their remaining throws guard null handles, unreadable or unwritable guest pointers and buffers, a foreign or finalized FreeType face, a null blob with a nonzero length, an out-of-range memory mode, or a failure to load the bundled ICU data. This moves the 22 guest-input sites to `GuestFault_nid_no_patch` and replaces the ICU-data failure with a plain `throw std::runtime_error("HarfBuzz ICU NFC data failed to load")`: `hb_icu_get_unicode_funcs` is implemented, and that failure is a host-resource failure, so neither `NotImplemented` ("not implemented") nor `GuestFault` ("guest input the console does not define") describes it. `tools/progress.py` counts both as throws, so libharfbuzz goes from 30 of 37 on current `main` to 37 of 37. Sites and their justification, checked against `3rdparty/harfbuzz` at the pinned 10.0.1 commit: - `Export.cpp` `hb_ft_face_create_cached` (6): null face (`hb-ft.cc` dereferences `ft_face->generic`/`stream`), unreadable guest record, a record without a live AnyPS5 FreeType owner (foreign layout), unreadable owner fields or a null/finalized host face (released `FT_Face`), and the two unwritable `generic` copies. - `Shaping.cpp` `hb_shape` (3): null buffer (`hb-shape.cc` reads `buffer->len`), null font or a null feature array of nonzero length (null `hb_memcpy` source in `hb-shape-plan.cc`), and an unreadable feature array. - `Lifecycle.cpp` `hb_blob_create` (1): null data with a nonzero length below 2 GiB (stored and later read), and an out-of-range memory mode (out-of-range enum conversion, no upstream behaviour). A length of 2 GiB or more is upstream-rejected and is not faulted. - `Layout.cpp` (12): null faces, unreadable caller counts, a null tag array with a nonzero count, and the host-write bracket and later writes over unwritable count/tag/index buffers. A null `count` or `index` is documented as optional and is not faulted. - `Buffer.cpp` (1): the bundled ICU data load, a plain throw as described above. No control flow changes; the same inputs throw at the same points. No technical-debt entry changes, so no fragment. This depends on the `GuestFault_nid_no_patch` helper (#23391); it is part of #23391's per-library migration. ### Tested Linux x86-64, GCC 16.2.1, Release build: - `cmake --build build --target guest_harfbuzz_tests guest_harfbuzz_buffer_tests guest_harfbuzz_font_tests`: builds and links. - `ctest --test-dir build -R 'harfbuzz'`: 19 of 19 tests pass. - The full Release suite on the same tree: 6,279 of 6,279 tests passed, 0 failed (554.7 s). - `python3 -I tools/progress.py --module libharfbuzz --json`: 37 of 37 (100.0%); current `main` reports 30 of 37. - `python3 -I tools/tests/test_progress.py`: 81 tests, OK. - `python3 -I tools/tests/test_progress_wrappers.py`: 13 tests, OK. - `python3 tools/check_conventions.py --base upstream/main`: all checks passed. ### 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 and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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: #23849 - [x] Fixes: none (part of #23391) - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Hermes Agent)
MarcZX10 commented 2026-11-20 12:07:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:07:38Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the reported test results are author-reported, and the inspected changes are consistent with the stated guest-fault classification.

What I ran

Reviewed head 7c142c5a411aa400a5767b52f0d19c975e2ac052. Used repo_read.py to inspect the prepared description, commits, manifest, diff, changed source ranges, and progress scanner context. No commands or tests were run; no merged-preview check was performed.

Results

Check Result Note
Source review passed Inspected all changed files
Tests not run Results in description are author-reported
Merged preview not run No preview inspected

Findings

Blocking

None.

Non-blocking

None.

Not verified

No runtime behavior, build, or test was independently verified. The description reports Linux x86-64 GCC 16.2.1 Release builds and test suites; those results were not reproduced here. All 11 changed files listed in the manifest were read; no changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5992398753 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23897#pullrequestreview-5992398753). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T12:07:38Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the reported test results are author-reported, and the inspected changes are consistent with the stated guest-fault classification. ## What I ran Reviewed head `7c142c5a411aa400a5767b52f0d19c975e2ac052`. Used `repo_read.py` to inspect the prepared description, commits, manifest, diff, changed source ranges, and progress scanner context. No commands or tests were run; no merged-preview check was performed. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Inspected all changed files | | Tests | not run | Results in description are author-reported | | Merged preview | not run | No preview inspected | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No runtime behavior, build, or test was independently verified. The description reports Linux x86-64 GCC 16.2.1 Release builds and test suites; those results were not reproduced here. All 11 changed files listed in the manifest were read; no changed files were excluded. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-22 20:10:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T20:10:26Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing in the inspected changes shows a blocking defect; the review is incomplete because the PR’s changed-file contents were not all read, so approval is not justified.

What I ran

  • Inspected the prepared diff for head 674a36a2f486c81f6b8bb7a8cc98c6e8425e2160 and read the listed changed files through repo_read.py.
  • No build or test commands were run.

Results

Check Result Note
Diff and inventory passed Read prepared review documents
Changed-code review not run Some changed files were not read
Build and tests not run No commands executed

Findings

Blocking

None identified in the code read.

Non-blocking

None.

Not verified

  • Read: AGENTS.md, CONTRIBUTING.md, core/libs/prx/libc/include/General.hpp, core/libs/prx/libc/src/General.cpp (changed lines), core/libs/prx/libharfbuzz/Buffer.cpp, core/libs/prx/libharfbuzz/Export.cpp, core/libs/prx/libharfbuzz/Layout.cpp, core/libs/prx/libharfbuzz/Lifecycle.cpp, core/libs/prx/libharfbuzz/Shaping.cpp, and tools/progress.py (changed lines); also read description.md, commits.md, manifest.json, and diff.patch.
  • Not read: docs/dev/PROGRESS.md and tools/tests/test_progress.py.
  • No tests or build were run. Author-reported test results were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014240859 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23897#pullrequestreview-6014240859). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T20:10:26Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing in the inspected changes shows a blocking defect; the review is incomplete because the PR’s changed-file contents were not all read, so approval is not justified. ## What I ran - Inspected the prepared diff for head `674a36a2f486c81f6b8bb7a8cc98c6e8425e2160` and read the listed changed files through `repo_read.py`. - No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and inventory | passed | Read prepared review documents | | Changed-code review | not run | Some changed files were not read | | Build and tests | not run | No commands executed | ## Findings ### Blocking None identified in the code read. ### Non-blocking None. ## Not verified - Read: `AGENTS.md`, `CONTRIBUTING.md`, `core/libs/prx/libc/include/General.hpp`, `core/libs/prx/libc/src/General.cpp` (changed lines), `core/libs/prx/libharfbuzz/Buffer.cpp`, `core/libs/prx/libharfbuzz/Export.cpp`, `core/libs/prx/libharfbuzz/Layout.cpp`, `core/libs/prx/libharfbuzz/Lifecycle.cpp`, `core/libs/prx/libharfbuzz/Shaping.cpp`, and `tools/progress.py` (changed lines); also read `description.md`, `commits.md`, `manifest.json`, and `diff.patch`. - Not read: `docs/dev/PROGRESS.md` and `tools/tests/test_progress.py`. - No tests or build were run. Author-reported test results were not independently verified. ## To get this to a good state Nothing is required.

Pull request closed

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!23897
No description provided.