test(libSceFreeType): leave a valid autofitter default script set #13512

Merged
jotitadev merged 1 commit from upstream-pr/13512 into main 2026-10-31 00:13:20 +00:00
jotitadev commented 2026-10-30 17:23:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T17:23:55Z.


What

GuestFreeTypeModuleProperties sets the autofitter default-script to 999 and 0xFFFFFFFF last. FreeType stores any default-script value without validating it, so the native and the guest libraries both keep 0xFFFFFFFF. The per-face increase-x-height queries added in #12668 then build the face globals with it: af_face_globals_compute_style_coverage finds no style for that script, keeps dflt = 0xFFFF and reads af_style_classes[0xFFFF], past the 88-entry table. It passes in normal builds only because the HarfBuzz-less af_shaper_get_coverage ignores the style class it gets.

Under ASan+UBSan both tests stop there:

3rdparty/freetype/src/autofit/afglobal.c:254:54: runtime error: index 65535 out of bounds for type 'AF_StyleClassRec *[88]'
    #0 af_face_globals_compute_style_coverage afglobal.c:254
    #1 af_face_globals_new afglobal.c:381
    #2 af_property_get_face_globals afmodule.c:89
    #3 af_property_get afmodule.c:332
    #4 QueryIncreaseXHeight core/libs/tests/GuestFreeTypeModuleProperties.cpp:89

The loop now tries the invalid values first and ends on a valid script, so every value is still compared against native FreeType. Test only; the adapter is unchanged. The nightly sanitizer run does not show this yet because guest_freetype_* are "Not Run" there until #12894 lets the ASan build finish.

Tested

Linux (Ubuntu 26.04, GCC 15.2, i7-8700), main 9f748f4d8e, with #12894 applied locally so the ASan build completes:

  • ASan+UBSan build (-DANYPS5_ENABLE_ASAN=ON, -fsanitize=undefined -fno-sanitize-recover=undefined -fno-sanitize=vptr, RelWithDebInfo), UBSAN_OPTIONS=halt_on_error=1: guest_freetype_module_properties and _nid fail on main with the report above and pass with this change (5 repeats). The rest of the non-GPU suite (1833 tests) had no other sanitizer report.
  • Normal RelWithDebInfo build: both tests pass with this change.
  • check_conventions.py and git diff --check pass.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5088375519 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13512). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-30T17:23:55Z. --- ### What `GuestFreeTypeModuleProperties` sets the autofitter `default-script` to `999` and `0xFFFFFFFF` last. FreeType stores any `default-script` value without validating it, so the native and the guest libraries both keep `0xFFFFFFFF`. The per-face `increase-x-height` queries added in #12668 then build the face globals with it: `af_face_globals_compute_style_coverage` finds no style for that script, keeps `dflt = 0xFFFF` and reads `af_style_classes[0xFFFF]`, past the 88-entry table. It passes in normal builds only because the HarfBuzz-less `af_shaper_get_coverage` ignores the style class it gets. Under ASan+UBSan both tests stop there: ``` 3rdparty/freetype/src/autofit/afglobal.c:254:54: runtime error: index 65535 out of bounds for type 'AF_StyleClassRec *[88]' #0 af_face_globals_compute_style_coverage afglobal.c:254 #1 af_face_globals_new afglobal.c:381 #2 af_property_get_face_globals afmodule.c:89 #3 af_property_get afmodule.c:332 #4 QueryIncreaseXHeight core/libs/tests/GuestFreeTypeModuleProperties.cpp:89 ``` The loop now tries the invalid values first and ends on a valid script, so every value is still compared against native FreeType. Test only; the adapter is unchanged. The nightly sanitizer run does not show this yet because `guest_freetype_*` are "Not Run" there until #12894 lets the ASan build finish. ### Tested Linux (Ubuntu 26.04, GCC 15.2, i7-8700), main `9f748f4d8e`, with #12894 applied locally so the ASan build completes: - ASan+UBSan build (`-DANYPS5_ENABLE_ASAN=ON`, `-fsanitize=undefined -fno-sanitize-recover=undefined -fno-sanitize=vptr`, RelWithDebInfo), `UBSAN_OPTIONS=halt_on_error=1`: `guest_freetype_module_properties` and `_nid` fail on main with the report above and pass with this change (5 repeats). The rest of the non-GPU suite (1833 tests) had no other sanitizer report. - Normal RelWithDebInfo build: both tests pass with this change. - `check_conventions.py` and `git diff --check` pass. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-30 17:29:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T17:29:22Z.

Review: APPROVED


Reviewed — looks good

The reordered test still checks both invalid script values against native FreeType and leaves a valid default script selected before the later face-property queries.

What I ran

Reviewed head c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc against base 6a3afa4deb18ea58a90efb8040fff8c60e4f2aab; the exact-head merge preview is clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5. No compiler or C++ test binary was run locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13512
git diff --check 6a3afa4deb18ea58a90efb8040fff8c60e4f2aab c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc
python3 tools/check_conventions.py --base 6a3afa4deb18ea58a90efb8040fff8c60e4f2aab --head c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc --title 'test(libSceFreeType): leave a valid autofitter default script set' --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13512-c1aff9498d15/pr-body.md
python3 tools/pr_stack_check.py 13512 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13512-c1aff9498d15/stack
python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/tests/GuestFreeTypeModuleProperties.cpp
gh pr checks 13512 --repo boykopovar/AnyPS5

Results

Check Result
Diff and conventions Passed.
Dependency/mergeability Exact head previews cleanly against the PR base; no declared dependency.
Test-quality heuristic It flagged the C++ test as possibly unregistered because the source path is constructed by CMake. Exact-head ModuleProperties.cmake registers guest_freetype_module_properties and _nid; this is a false positive.
Hosted CI Five policy checks were pending at final refresh; none runs these C++ tests.
FreeType tests and sanitizer control The PR reports normal RelWithDebInfo runs passing and both FreeType module-property tests passing five times under ASan+UBSan after failing on main with an out-of-bounds style-table access. The author reports applying #12894 locally to make the sanitizer build complete. I did not reproduce these runs.
Unedited output from local checks

git diff --check exited 0 and emitted no output.

All conventions checks passed.
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13512-c1aff9498d15/head-c1aff9498d15-d69626aa/tools/pr_test_quality.py': [Errno 2] No such file or directory

The local heuristic rerun returned:

{
  "findings": [
    {
      "path": "core/libs/tests/GuestFreeTypeModuleProperties.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}
# PR stack check — fresh

Target: https://github.com/boykopovar/AnyPS5/pull/13512
Target branch tip: `6a3afa4deb18ea58a90efb8040fff8c60e4f2aab`
All heads unchanged: **True**
Dependency order: #13512

## Individual merge previews

- PR #13512: **clean** against current base; head `c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc`; changed paths: none reported

## Dependency relationships

No declared PR dependencies were found in the target PR chain.
conventions	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41098477063/job/124210316841
eligibility	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41098476946/job/124210312647
intake	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41098477084/job/124210316263
labels	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41098477014/job/124210315650
library-portability	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41098477038/job/124210312574

Sources

Not verified

I did not build or run the tests locally, independently reproduce the sanitizer failure or fix, verify the author's reported base commit, or run Windows or console tests. The reported sanitizer run used #12894 applied locally; that PR remains open.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5716133212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13512#pullrequestreview-5716133212). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T17:29:22Z. **Review:** APPROVED --- # Reviewed — looks good The reordered test still checks both invalid script values against native FreeType and leaves a valid default script selected before the later face-property queries. ## What I ran Reviewed head `c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc` against base `6a3afa4deb18ea58a90efb8040fff8c60e4f2aab`; the exact-head merge preview is clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5. No compiler or C++ test binary was run locally. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13512 git diff --check 6a3afa4deb18ea58a90efb8040fff8c60e4f2aab c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc python3 tools/check_conventions.py --base 6a3afa4deb18ea58a90efb8040fff8c60e4f2aab --head c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc --title 'test(libSceFreeType): leave a valid autofitter default script set' --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13512-c1aff9498d15/pr-body.md python3 tools/pr_stack_check.py 13512 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13512-c1aff9498d15/stack python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/tests/GuestFreeTypeModuleProperties.cpp gh pr checks 13512 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff and conventions | Passed. | | Dependency/mergeability | Exact head previews cleanly against the PR base; no declared dependency. | | Test-quality heuristic | It flagged the C++ test as possibly unregistered because the source path is constructed by CMake. Exact-head `ModuleProperties.cmake` registers `guest_freetype_module_properties` and `_nid`; this is a false positive. | | Hosted CI | Five policy checks were pending at final refresh; none runs these C++ tests. | | FreeType tests and sanitizer control | The PR reports normal RelWithDebInfo runs passing and both FreeType module-property tests passing five times under ASan+UBSan after failing on `main` with an out-of-bounds style-table access. The author reports applying #12894 locally to make the sanitizer build complete. I did not reproduce these runs. | <details> <summary>Unedited output from local checks</summary> `git diff --check` exited 0 and emitted no output. ```text All conventions checks passed. ``` ```text /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13512-c1aff9498d15/head-c1aff9498d15-d69626aa/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` The local heuristic rerun returned: ```json { "findings": [ { "path": "core/libs/tests/GuestFreeTypeModuleProperties.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` ```text # PR stack check — fresh Target: https://github.com/boykopovar/AnyPS5/pull/13512 Target branch tip: `6a3afa4deb18ea58a90efb8040fff8c60e4f2aab` All heads unchanged: **True** Dependency order: #13512 ## Individual merge previews - PR #13512: **clean** against current base; head `c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc`; changed paths: none reported ## Dependency relationships No declared PR dependencies were found in the target PR chain. ``` ```text conventions pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41098477063/job/124210316841 eligibility pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41098476946/job/124210312647 intake pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41098477084/job/124210316263 labels pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41098477014/job/124210315650 library-portability pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41098477038/job/124210312574 ``` </details> ## Sources - [The pinned FreeType submodule stores `default-script` without range validation](https://github.com/freetype/freetype/blob/37515cf56ba3349656049edbed89ffc6f6466f2d/src/autofit/afmodule.c#L156) - [The same pinned FreeType revision indexes `af_style_classes` using the selected default-script index](https://github.com/freetype/freetype/blob/37515cf56ba3349656049edbed89ffc6f6466f2d/src/autofit/afglobal.c#L254) - [The reordered values and subsequent face-property queries at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc/core/libs/tests/GuestFreeTypeModuleProperties.cpp#L154) - [The test's CMake registration at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/c1aff9498d1519fefb3f2a5906e6d8bdbdd1fabc/core/libs/prx/libSceFreeType/ModuleProperties.cmake#L4) ## Not verified I did not build or run the tests locally, independently reproduce the sanitizer failure or fix, verify the author's reported base commit, or run Windows or console tests. The reported sanitizer run used #12894 applied locally; that PR remains open.
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!13512
No description provided.