Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
jotitadev:fix/freetype-test-invalid-default-script
Oct 31, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
jotitadev:fix/freetype-test-invalid-default-script

Conversation

@jotitadev

Copy link
Copy Markdown
Contributor

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

The script loop set default-script to 999 and 0xFFFFFFFF last. FreeType
stores any default-script value, so both libraries kept 0xFFFFFFFF, and the
per-face x-height queries that follow computed the face globals with it:
af_face_globals_compute_style_coverage found no style for that script and
read af_style_classes[0xFFFF], past the 88-entry table (afglobal.c:254).

Try the invalid values first so the loop ends on a valid script.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@maskym

maskym commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Windows result for head c1aff9498d, merged into main 223b19ba0a (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. Build clean.

The tree also carried the open PR #13490, merged cleanly, so the run is a joint one. guest_freetype_module_properties and guest_freetype_module_properties_nid, the tests this PR changes, pass; the touched modules' set passes 6/6, three runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@adriadam10 adriadam10 self-assigned this Oct 30, 2026
@adriadam10
adriadam10 merged commit 8134960 into boykopovar:main Oct 31, 2026
11 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the reorder: both invalid script values are still compared against native FreeType for fallback-script and default-script, and each loop now ends on FT_AUTOHINTER_SCRIPT_INDIC, so the later increase-x-height queries no longer index af_style_classes out of range. Windows check and the third-party Windows run are green; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants