Skip to content

fix(libSceFreeTypeOt): free Raccess buffers when FT_Raccess_Get_DataOffsets throws - #16367

Closed
MarcZX10 wants to merge 2 commits into
boykopovar:mainfrom
MarcZX10:fix/libscefreetypeot-raccess-data-offsets-leak
Closed

MarcZX10 wants to merge 2 commits into
boykopovar:mainfrom
MarcZX10:fix/libscefreetypeot-raccess-data-offsets-leak

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

What

FT_Raccess_Get_DataOffsets (libSceFreeTypeOt/src/Raccess.cpp) allocates a reference table and a result array and then throws through NotImplemented_nid_no_patch when the offset sum overflows or when the caller's offsets pointer is null. Both throws happened after the allocations, so the buffers were never released.

  • fix(libSceFreeTypeOt): free Raccess buffers when DataOffsets throws: the null offsets check moves next to the existing null count check, before any allocation; the loop that sums the data offsets is wrapped so that the result array and the reference table are freed before the exception continues. Return codes and the count write are unchanged (*count is still written where it was; an existing test asserts that after a read error).
  • test(libSceFreeTypeOt): cover Raccess buffer release on DataOffsets throws: two cases in GuestFreeTypeOtRaccess.cpp (a null offsets with a matching tag, and a resource data position that overflows the sum). Each expects the throw and checks that the allocations and frees of the guest allocator balance. The file defines a throwing NotImplemented_nid_no_patch for the test, as GuestJsonFloatFailure.cpp does.

PR #16121 adds helpers and a new FT_Raccess_Guess in the same file but does not touch the body of FT_Raccess_Get_DataOffsets.

Tested

Linux, throwaway archive build of this head: BUILD-EXIT 0, ctest guest_freetype_ot_raccess (target guest_freetype_ot_raccess_tests) passed, 1 of 1. python3 tools/check_conventions.py against the merge base and git diff --check are clean. The new cases were not run against the unfixed code; that they fail without the fix is reasoned from the code (the unfixed paths allocate 2 and free 0). Not run on Windows or macOS.

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

FT_Raccess_Get_DataOffsets allocated the reference array before checking
the offsets argument, and held the reference array while it converted
the references to offsets. A null offsets pointer or a resource offset
that overflows when added to rdataPos threw NotImplemented with both
blocks still allocated.

Check the offsets argument next to the count argument, before any
allocation, and free both blocks before rethrowing from the offset sum.
Return values and the count written before the reference reads are
unchanged.
…hrows

Add two cases to the Raccess test: a null offsets pointer with a matching
tag, and a resource offset that overflows when added to rdataPos. Both
must throw NotImplemented and leave the allocation and free counts equal.
Before the fix the null offsets case and the overflow case each left
their reference array (and, for the overflow, the offset array) allocated.
@github-actions github-actions Bot added the prx label Nov 6, 2026
@JJenkx

JJenkx commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 52c7c06db0, merged onto main e8b1bd3d7f (aede71d952, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_freetype_ot_raccess passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 52c7c06db0, applied with git apply (with -C1, context shifted) on main fd4aeed483 together with the other 26 PRs of one batch (#16415, #22363, #23103, #23366, #24064, #21547, #21742, #22774, #22852, #23420, #23952, #24346, #16945, #21718, #21780, #21912, #21931, #22061, #22425, #22619, #22657, #18765, #19662, #19767, #20899, #21571). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
guest_freetype_ot_raccess (1 test, matched by name to the test file this PR changes) all pass outside the iGPU subset

Whole batch: the full ctest -j 12 (6523 tests) on the RTX 3080 has 4 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. The 2126 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

This was referenced Nov 21, 2026
@github-actions

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 27983 core/libs/tests/GuestFreeTypeOtRaccess.cpp L6-8, L182

@oneandonlydean

Copy link
Copy Markdown
Collaborator

I am closing this for now. The fix itself looked right, but the new test pins two NotImplemented paths with RequireThrows, which we ask to be dropped, and there has been no push since 6 Nov. Feel free to reopen after dropping those two checks at any time and we will look at it again.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants