You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(libSceFreeTypeOt): release references when result allocation throws - #28337
Release the allocated reference table (OtMemFree(memory, ref)) if OtMemRealloc throws while allocating the result array in FT_Raccess_Get_DataOffsets_nid_postfix, then rethrow the original exception. Distinct from open PR #16367, which moves the null offsets check and catches exceptions in the post-allocation Add() loop but does not free ref if OtMemRealloc itself throws.
Tested
macOS arm64, Apple Clang, production libSceFreeTypeOt raccess component (Raccess.cpp, Memory.cpp, Stream.cpp). The regression test in GuestFreeTypeOtRaccess.cpp fails against unmodified main (FreeType Ot raccess: offset allocation failure frees the reference table) and passes with the fix (Guest FreeType Ot raccess tests passed), verifying both null-returning and throwing result allocation paths leave caller outputs untouched and free the reference array. tools/check_conventions.py, tools/debt_fold.py --check, and git diff --check passed. Full CMake build, runtime, and console testing remain outstanding.
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
Improved reliability when memory allocation fails while retrieving FreeType resource offsets. Temporary memory is released, the original error or exception is preserved, and output values remain unchanged when the operation fails.
Tests
Added checks for allocation failures to verify that memory cleanup and error handling work as expected.
Allocation failure cleanup and validation core/libs/prx/libSceFreeTypeOt/src/Raccess.cpp, core/libs/tests/GuestFreeTypeOtRaccess.cpp, docs/dev/debt/changes/fix-freetype-raccess-allocation-exception.md
The function frees the reference array and rethrows if result-offset allocation throws. Tests verify exception propagation, error 0x40 on a null return, unchanged caller outputs, and cleanup. The debt entry records console behavior as unverified.
This change frees a temporary reference array when the result allocation throws, which fixes a leak on that failure path. Tests cover both failure modes. No concrete merge-blocking risk remains, though console behavior has not been verified.
Security architecture risk: Low · up to 828f6
The fix releases temporary memory when result allocation fails. The remaining risk is narrow: if releasing that memory also throws, callers receive the cleanup exception instead of the original allocation error.
Retained concerns
Trivial · reliability · inferred: If result allocation throws and the allocator’s free callback also throws, the new cleanup path replaces the original exception. The base propagated the original exception without attempting cleanup. The callback interface permits the secondary throw, but no production binding that throws was established.
inferred — The changed behavior is confined to an invocation that has already parsed the reference table and then encounters a result-allocation exception. It adds no new input source or allocator authority: cleanup uses the same callback and temporary allocation already used on the normal and null-return paths.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
The reason will be displayed to describe this comment to others. Learn more.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 828f6f5f36:
Conventions: tools/check_conventions.py passed.
Build: guest_freetype_ot_raccess_tests built cleanly.
CTest (guest_freetype_ot_raccess):
1/1 Test #4450: guest_freetype_ot_raccess ........ Passed 0.01 sec
100% tests passed, 0 tests failed out of 1
Negative control: with core/libs/prx/libSceFreeTypeOt/src/Raccess.cpp reverted to main and the new tests kept, the suite fails:
1/1 Test #4450: guest_freetype_ot_raccess ........***Failed 0.01 sec
0% tests passed, 1 tests failed out of 1
Restoring the change makes it pass again.
Code reading:
Verified that OtMemFree(memory, ref) is invoked in the catch block within FT_Raccess_Get_DataOffsets_nid_postfix before rethrowing exceptions from OtMemRealloc (Raccess.cpp:268-270).
Checked that the non-exceptional error branch (error != 0) continues to free ref via OtMemFree(memory, ref) at Raccess.cpp:278 before returning error.
Verified that caller output pointers (*count, *offsets) are not overwritten with allocated buffers when an allocation exception occurs.
Audited debt fragment docs/dev/debt/changes/fix-freetype-raccess-allocation-exception.md for proper format and compliance with AGENTS.md.
Audited GuestFreeTypeOtRaccess.cpp tests for thorough verification of both nullptr-return and throwing allocation paths.
The reason will be displayed to describe this comment to others. Learn more.
Architecture findings (1)
Advisory architecture findings (1)
Trivial — If result allocation throws and the allocator’s free callback also throws, the new cleanup path replaces the original exception. The base propagated the original exception without attempting cleanup. The callback interface permits the secondary throw, but no production binding that throws was established.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 5b39299b-ba2e-40e8-ba30-60d0adda27ad
Commits
Reviewing files that changed from the base of the PR and between 611e780 and 828f6f5.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head 828f6f5f3643bed03aecbf2670b5c4019cbeb38c. No commands or tests were run in this review. The author reports running the regression test and convention/debt/diff checks on macOS arm64; those results were not independently verified.
Results
Check
Result
Note
Diff and changed files
passed
Three changed files reviewed
Automated checks
not run
Author reports checks passed
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported tests, full CMake build, runtime behavior, and console behavior were not verified. Read: core/libs/prx/libSceFreeTypeOt/src/Raccess.cpp, core/libs/tests/GuestFreeTypeOtRaccess.cpp, docs/dev/debt/changes/fix-freetype-raccess-allocation-exception.md, and the prepared description, commits, manifest, and diff. No changed files were excluded by the manifest.
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.
Validation-layer protocol on main and on this PR (ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation 1.4.366, VK_LOADER_DEBUG=error,warn,layer, ctest -R '^(agc|guest_video_out|video_out|pad_sdl)' --parallel 4 -V):
Tree
Passed
Layer inserted
was not found but was requested
VUID- set
main
2464/2465
2214
0
none
this PR
2465/2465
2214
0
identical
No new validation errors and no test failures on this PR's tree. agc_driver_queue_zero_quiet_interrupt failed in the main run but passed in this PR's run.
The tests this PR adds or changes (agc_driver_native_depth_aliased_depth_depth_only, agc_driver_native_depth_aliased_depth_no_stencil, agc_driver_native_depth_aliased_depth_stencil, agc_driver_native_depth_aliased_stencil, agc_driver_native_depth_bare_publication, agc_driver_native_depth_buffer_clear, agc_driver_native_depth_clear_refusals, agc_driver_native_depth_clear_supersedes_plane_writes, agc_driver_native_depth_clears, agc_driver_native_depth_colour_import, agc_driver_native_depth_covered_owner, agc_driver_native_depth_demand_zero, agc_driver_native_depth_demand_zero_race, agc_driver_native_depth_demand_zero_stencil, agc_driver_native_depth_demand_zero_stencil_race, agc_driver_native_depth_discarded_clear, agc_driver_native_depth_driver_path, agc_driver_native_depth_expand_gate, agc_driver_native_depth_fill_over_pending_import, agc_driver_native_depth_htile_plane_alias, agc_driver_native_depth_initial_owner, agc_driver_native_depth_other_identity, agc_driver_native_depth_overwritten_planes, agc_driver_native_depth_overwritten_published, agc_driver_native_depth_pending_units, agc_driver_native_depth_publication, agc_driver_native_depth_publication_without_htile, agc_driver_native_depth_retirement, agc_driver_native_depth_separate_stencil, agc_driver_native_depth_single_sample_view, agc_driver_native_depth_smaller_extent, agc_driver_native_depth_stencil, agc_driver_native_depth_stencil_plane_memory_read, agc_driver_native_depth_stencil_view, agc_driver_native_depth_stored_repeat_fill, agc_driver_native_depth_uneven_plane, agc_driver_native_depth_uniform_plane_alias, agc_driver_native_depth_uniform_planes, agc_driver_native_multisample_depth) pass in the full validation-layer run. agc_driver_native_depth_driver_queued_fill is skipped on this machine (skipped, host imports are compared here, not write-watched, and a queued fill's HTILE proof needs a write-watched import), so there is no result for it here. gnm_shader_writers, guest_freetype_ot_raccess are outside that filter and pass 2/2 in three separate runs. Not run on a PS5.
AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.
The reason will be displayed to describe this comment to others. Learn more.
The Linux guest_freetype_ot_raccess CTest passed against the patched library. The new fixture checks both a failed return and a thrown allocation after the reference table is created. It verifies one cleanup, the original error or exception, and unchanged caller outputs.
The reason will be displayed to describe this comment to others. Learn more.
I read the diff at 828f6f5f36. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged into main at b97867d3ce6 together with other open PRs (so not an isolated build).
guest_freetype_ot_raccess: pass on both.
Control (same tree and tests, the changed files of those PRs put back to main's): fails on both with "offset allocation failure frees the reference table".
The red rollup is only cancelled conventions and labels runs; no check failed.
Not checked: a title.
AI-assisted: yes (Claude Code)
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Release the allocated reference table (
OtMemFree(memory, ref)) ifOtMemReallocthrows while allocating the result array inFT_Raccess_Get_DataOffsets_nid_postfix, then rethrow the original exception. Distinct from open PR#16367, which moves the nulloffsetscheck and catches exceptions in the post-allocationAdd()loop but does not freerefifOtMemReallocitself throws.Tested
macOS arm64, Apple Clang, production
libSceFreeTypeOtraccess component (Raccess.cpp,Memory.cpp,Stream.cpp). The regression test inGuestFreeTypeOtRaccess.cppfails against unmodifiedmain(FreeType Ot raccess: offset allocation failure frees the reference table) and passes with the fix (Guest FreeType Ot raccess tests passed), verifying both null-returning and throwing result allocation paths leave caller outputs untouched and free the reference array.tools/check_conventions.py,tools/debt_fold.py --check, andgit diff --checkpassed. Full CMake build, runtime, and console testing remain outstanding.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit