Skip to content

fix(agc): release cached address space on device teardown - #4849

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/fix-address-cache-shutdown-4846
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarcZX10:codex/fix-address-cache-shutdown-4846

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

GuestBufferMemory::AcquireRegistered can publish an address space that holds leases for every registered GPU allocation. ClearImageMirrors used to release that cache only after confirming the mirror table belonged to the device. When lease mirrors are disabled, the mirror table has no device, so teardown returned early and left the address-space cache pinning allocations after the Vulkan device was destroyed.

Clear the cached address space by its own device identity before the mirror-table early return. Add a focused mock-Vulkan regression that builds an address space with APS5_NO_LEASE_MIRROR=1, tears it down, and confirms freeing its allocation does not need the pin waiter's cache-drop fallback. The regression fails against the old teardown logic.

Related to #4846. The reported ProsperoEden exit hang also reproduces with APS5_NO_ADDRESS_SPACE_CACHE enabled, so this cache cleanup is not established as the cause or fix for that issue. The test covers a separate lease cleanup regression when lease mirrors are disabled.

Tested

Linux, GCC 12.2, Release, Ninja, ANYPS5_ENABLE_SPIRV_TOOLS=OFF.

  • agc_driver_address_space_teardown passes. Restoring the old cleanup order makes it fail with device teardown left the cached address space pinning guest allocations.
  • agc_driver_graphics passes (15.78 s).
  • python3 tools/check_conventions.py --base upstream/main and git diff --check pass.
  • Tests use the mock Vulkan context; no physical GPU was involved.

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 (not applicable)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none confirmed
  • AI-assisted: yes, Codex

@MarcZX10
MarcZX10 force-pushed the codex/fix-address-cache-shutdown-4846 branch from bd24521 to abc997b Compare October 13, 2026 05:46
@github-actions

github-actions Bot commented Oct 13, 2026 •

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
#4446 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L2882-2883, L5597
#4783 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp L5597

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Validation on the rebased head abc997b0daf691918aa8ae681debdc10c43328d4:

  • Release Ninja build of agc_driver_graphics_tests completed.
  • agc_driver_address_space_teardown passed (1/1).
  • tools/check_test_registration.py, tools/check_conventions.py --base upstream/main --head HEAD, and git diff --check passed.
  • Hosted eligibility, conventions, and report checks pass; GitHub currently reports the PR mergeable.

The overlap report flags nearby changes to Graphics.cpp in #757 and #758. This fix does not depend on either; I’ll account for those edits if either lands first.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Please drop Fixes #4846. The issue reproduces with APS5_NO_ADDRESS_SPACE_CACHE set and with lease mirrors on, so this cache isn't what holds its lease; #4872 fixes the exit order and the title's run there goes from 134 to 0. The early return in ClearImageMirrors (GuestBufferMemory.cpp:1791) is still a real leak, so this stays open on its own. Which run reaches it without APS5_NO_LEASE_MIRROR?

@oneandonlydean oneandonlydean self-assigned this Oct 13, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for the correction. The ProsperoEden report reproduces with APS5_NO_ADDRESS_SPACE_CACHE enabled and lease mirrors on, and #4872 addresses the reported exit-order failure. I removed “Fixes #4846” and clarified that this PR only tests cache lease cleanup when lease mirrors are disabled; the current evidence does not establish that this change fixes the reported ProsperoEden hang.

@oneandonlydean
oneandonlydean merged commit feddf7f into boykopovar:main Oct 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants