fix(libcairo): fault context pointers that Cairo dereferences #28898
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28898"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by LODIBIDO on 2026-12-04T14:46:07Z.
What
Moves the pointer rejections in
core/libs/prx/libcairo/Context.cpptoGuestFault_nid_no_patch(#28739), and follows Cairo's early return for a context in error. Part of #23391. Same approach as #23881 does forMatrix.cpp.Basis: Sony publishes Cairo source for the PS5 as one archive per system software range, from 1.00 to 9.00 and later, and
docs/dev/debt/libcairo.mdrecords that these exports run Cairo 1.18.0 against PS5 9.00 and later, where Sony's behaviour-changing patch concerns surface images. I did not open the archives; firmware before 9.00 is unchecked. In 1.18.0 these paths dereference the pointer unconditionally:cairo_transform,cairo_set_matrix: unreadablematrix.cairo_get_matrix: unwritablematrix.cairo_user_to_device,cairo_user_to_device_distance,cairo_device_to_user,cairo_device_to_user_distance: unreadable or unwritable coordinate.cairo_get_dash: unwritable non-nulldashes, inaccessible non-nulloffset.cairo_get_current_point,cairo_path_extents,cairo_fill_extents,cairo_stroke_extents,cairo_clip_extents: unwritable non-null output.Behaviour change: on a context in error,
cairo_transform,cairo_set_matrix, the four coordinate transforms,cairo_set_dashandcairo_get_dashnow return without checking the pointers, as Cairo does, instead of throwing.On a valid context, rejected
cairo_set_dasharrays still callNotImplemented_nid_no_patch: Cairo can stop on a negative element before reaching an unreadable one, so not every rejected input faults.#19529 and #28015 add other functions to
Context.cpp.Console behaviour is not measured. No title is known to be unblocked.
Tested
Native Intel Mac (x86_64, macOS 15.7.8, Apple clang 17.0.0), Release, with the diffs of #27201 and #27767 applied locally.
ctest -R '^guest_cairo': 42 of 42 passed.guest_cairo_context_guest_pointerspassed 5 of 5 runs.Context.cppfrommainfails.ctest -R '^public_headers'65 of 65.tools/progress.py --compare:libcairo114 to 127 of 161.Not tested: Windows, Linux, console.
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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T14:55:03Z.
Review: COMMENTED
Actionable comments
46fae72f-c707-47df-bc17-d003bce0cc05Reviewing files that changed from the base of the PR and between
8037ad561dandd3a73e46e8.core/libs/prx/libcairo/Context.cppcore/libs/tests/GuestCairoContextGuestPointers.cppdocs/dev/debt/changes/fix-cairo-context-guest-pointers.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T15:03:27Z.
Review: APPROVED
Reviewed — looks good
The reviewed change matches the stated pointer-fault and Cairo error-context behavior, with no verified blocking defects at
d3a73e46e8f839531b91d787199277195823881a.What I ran
Reviewed the prepared diff and all three changed files at the pinned head. Used
repo_read.pyfor targeted source context. No checks were run by me; the tests in the description are author-reported.Results
Negative control
Not run by me. The author reports the new test fails against
main'sContext.cpp.Findings
Blocking
None.
Non-blocking
None.
Sources
Context.cppat the reviewed headGuestFault_nid_no_patchdeclaration and repository guidanceNot verified
No tests or builds were run. Windows, Linux, console behavior, and the behavior of Sony's Cairo archives were not independently verified. The prepared review lists no excluded changed files.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T15:47:34Z.
Review: APPROVED
Verified head
d3a73e46e8on Windows 11 with GCC 15.2, applied to main484b0368d3.guest_cairo_context_guest_pointers: passes on main, and passes with this PR.Context.cppreverted and the test kept, it fails at line 253,EXPECT_FAULT(cairo_set_matrix(context, nullptr)): main rejects the pointer throughNotImplemented_nid_no_patch, which the new check counts.Checked against Cairo 1.18.0
cairo.c:cairo_set_matrix,cairo_transform, the four coordinate transforms,cairo_set_dashandcairo_get_dashreturn at once whencr->statusis set.cairo_get_matrix,cairo_get_current_point,cairo_path_extentsandcairo_clip_extentsstill write their outputs on a context in error. That matches the newEXPECT_FAULTcases.AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.