Repository navigation
fix(libSceFont): clear the device cache ownership flag when an owned buffer is detached - #29126
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The ownership flag is cleared after an owned cache buffer is detached, and the added regression checks that a subsequent caller-owned buffer is returned without deallocation.
What I ran
Reviewed head 9989c49c7693d4599a72023ff8e70212d21d5a5a against the prepared diff and pinned source using repo_read.py; no merged-preview check or tests/builds were run.
repo_read.py cat core/libs/prx/libSceFont/src/Library.cpp 200 245
repo_read.py cat core/libs/prx/libSceFont/src/Library.cpp 330 485
repo_read.py search flags core/libs/prx/libSceFont/src/Library.cpp
repo_read.py cat core/libs/tests/GuestFont.cpp 890 940
repo_read.py cat core/libs/tests/GuestFont.cpp 1000 1032
repo_read.py search AttachDeviceCacheBuffer core/libs/tests/GuestFont.cpp
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Both changed files inspected |
| GuestFont tests | not run | The description reports 30 passed and 1 skipped |
Negative control
Not run; the reported red test was author-run, not independently verified.
Findings
Blocking
None.
Non-blocking
None.
Sources
- Library.cpp at the reviewed head shows ownership being set on library allocation and cleared after the owned detach path.
- GuestFont.cpp at the reviewed head contains the regression sequence and allocation-count assertion.
Not verified
Tests and builds were not run. Real PS5 firmware behavior and a direct destroy-path regression were not verified. Read the relevant sections of core/libs/prx/libSceFont/src/Library.cpp and core/libs/tests/GuestFont.cpp; files.json lists no excluded files.
To get this to a good state
Nothing required.
What
sceFontDettachDeviceCacheBuffersets the device-cache ownership bit (flagsbit 0) when the library allocates the cache buffer itself (core/libs/prx/libSceFont/src/Library.cpp:394,lib->flags |= owned), but never clears it when that owned buffer is detached (:465-470). The bit therefore describes the last owned attach, not the currently attached buffer: after an owned detach, a caller-attached buffer is treated as library-owned, so the next detach returnsnullptr/0instead of the caller's pointer and capacity and callslib->iface->deallocon memory the library never allocated (:467).sceFontDestroyLibrary(:222) has the same consequence and frees a caller-owned buffer.Reproduced on upstream
main(2e5e1aab, Release, Linux): aftersceFontAttachDeviceCacheBuffer(lib, nullptr, 0x2000)→ detach, attaching a caller buffer and detaching it returnedbuffer=(nil),size=0and dropped the library's allocation counter34 -> 33; detaching a callermmap'd buffer after an owned detach crashed withSIGSEGV(exit 139) inside glibcfree, withlibSceFont.prx+0x1b7e6on the stack.This change clears the bit in the owned detach branch before the cache slot is released, so it also runs when
iface->deallocis unavailable. After the fix the invariant holds: bit 0 is set iff the attached buffer was allocated by the library (:394sets it only whenbuffer == nullptr), so the caller-buffer detach returns the caller's pointer and capacity and neither detach nor destroy deallocates caller memory. The flag is used only at:222,:394,:446and the new:470, andlibSceFontFtinitialisesflags = 0x60000000, so clearing bit 0 leaves the driver flags intact.The regression extends
core/libs/tests/GuestFont.cppafter the existing owned attach/detach checks (:1017-1018): owned attach → detach → callerstd::vectorattach → detach must returncallerCache.data()/0x2000and leave theallocationscounter unchanged.Overlap note:
tools/pr_overlap.pyreports open PR #22639 as sharinglibSceFont/src/Library.cpp, which is the documented feature-vs-fix false positive. #22639's only hunk in that file is@@ -205,7 +205,10 @@ sceFontDestroyLibrary(term-callback error propagation,:205-215); it does not touch the detach branch at:465-470. The open PRs touchingtests/GuestFont.cppare #28338 (:1296) and #20216 (:557), both far from the insertion at:1019-1027. No open PR or issue mentionssceFontDettachDeviceCacheBuffer(the only merged reference is #20775).Branch currency: upstream
mainmoved from the commit this was reviewed against (6e3ed265) to2e5e1aab, then toc0d8d6c2, during preparation.mainwas merged into the branch (no rebase, no force-push) and the tree was rebuilt and retested after each merge. Both files this PR touches are byte-identical on currentmain(Library.cppblob2dcc4290,GuestFont.cppblobfd3948d3), so neither merge changed an approved file; the diff against currentmainis exactly the reviewed 10-line change.Tested
Linux (container, x86-64), Release build,
BUILD_TESTING=ON, full tree built with Ninja../build/tests/guest_font_testsfails withFont check failed at line 1026(exit 134) — line 1026 is the new caller-buffer detach assertion.ctest --test-dir build -R '^guest_font$' -V→1/1 Test #4460 guest_font Passed; the binary run directly exits 0.ctest -R '^(guest_font|font_)' -E fontconfig -V→ 30 passed, 1 skipped (guest_font_output_pointers_watched, environment-gated: no userfaultfd in this container), 0 failed.mainmerged in:ninja -C build→ exit 0, no failures.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)mainbefore the fix)Summary by CodeRabbit