fix(agc): synchronize ResourceCache index on list node eviction #9592
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9592"
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 christophermonterocortes-cr on 2026-10-22T03:41:26Z.
What
In
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, ensureResourceCacheindex entries are always synchronized and erased when list nodes are evicted.eraseEntry(iterator)helper that erases the corresponding index entry for a list node, falling back to iterator matching across the index map if the key lookup misses.eraseEntryacross all node eviction paths: capacity eviction, table-element budget eviction,RemoveImage, anddropReleasedTextures.indexwhen list nodes are deallocated, fixing theSIGSEGVcrash inResourceCache::Findduring MXGP 26 (PPSA30839) loading (#9497).docs/dev/debt/libSceAgcDriver.mdwith technical debt notes.Tested
python tools/check_conventions.py --base upstream/main: All conventions checks passed.python -m unittest discover -s tools/tests -p "test_check_conventions*.py": all passed.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:09:56Z.
Review: CHANGES_REQUESTED
This PR addresses the dangling-index failure described in #9497, but it is not ready to approve under the repository contribution rules. The generated overlap report lists many open PRs touching ShaderResources.hpp/.cpp (including #6192, #6194, #6202, #6223, #6292, #6412, #6481, #6615, #7642, #7689, #7800, #8672, #9012 and #9508); for these files the report says the comparison could not complete because their branches conflict with the base. Please manually resolve the implementation overlap and coordinate ordering with the relevant authors, recording
Depends on: #Nwhere a prerequisite exists. The same-key erase and iterator-fallback change may interact with those cache edits, so the debt-file overlap alone does not settle this.The checklist also says
Unblocks: PPSA30839without a Game bring-up discussion number. Please link the applicable discussion or usenoneif this is not a title unblock. Lastly, this is an AGC driver change; the reported issue reproduction is valuable, but the PR currently reports only convention checks. Please attach same-machine/same-GPU focused ctest -V runs for current main and this head with the required validation-layer environment, verify layer loading, compare VUIDs, and state GPU/driver/OS. The reported reproducer uses maina6dcea9279, which is not current main.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T10:01:04Z.
Review: CHANGES_REQUESTED
I inspected the exact helper and found an edge in the failure case this PR is intended to tolerate.
eraseEntry(it)erasesindex.find(it->first)whenever that key exists, without checking that the map value isit. If the corrupted list key now equals another live entry's key, lookup succeeds and removes the other node's index mapping; the current node's map entry can still point at its freed list node. Please requirefound->second == itbefore erasing by key, and otherwise take the iterator-matching fallback. Add focused coverage for a key miss and a collision with another live key if the cache test seam permits it.The focused bug report and fix are important, but the current validation is still incomplete: this branch is 100 commits behind current main; the linked MXGP reproduction is from
a6dcea9279; and hosted product/relinker jobs are skipped. Please rebase, reproduce the issue or run a focused ResourceCache regression on current main and this head, then provide the paired AGC validation-layer/no-cachectest -Vresults required by CONTRIBUTING (layer loaded, compare VUIDs, GPU/driver/OS).The overlap bot cannot compare multiple open PRs changing
ShaderResources.hpp/.cpp; manually compare the relevant cache changes and agree merge order/dependencies with their authors. The #9497 report is a bug issue, not a Game bring-up discussion. Since the checklist saysUnblocks: PPSA30839, please locate/create the title's Game bring-up discussion, list this PR there, and use the requiredPPSA30839 #<discussion>form. KeepFixes: #9497if this fix continues to address that issue.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-22T18:55:39Z.
Review: CHANGES_REQUESTED
Thanks for the patch. Changes needed before this can merge:
ShaderResources.cpp:3937-3941:eraseEntryerasesindex.find(it->first)without checkingfound->second == it. If the list key is the corrupted copy and collides with another live entry's key, this removes that entry's mapping and leaves the current node's mapping pointing at the freed node. Requirefound->second == it, otherwise take the iterator scan.ShaderResources.cpp:3942-3947: the fallback only runs once a node's key and its index entry have already diverged, so it hides the inconsistency instead of fixing where it starts, and each miss is an O(n) scan on the eviction path. #9497 is still being diagnosed (key copies compared before each erase); the fix should target whatever corrupts or desynchronizes the key (anInsert/erase(key)path leaving a map entry on a replaced node), not tolerate it.Testedlists only convention checks. Add a focused test that fails without the change (key miss and key collision cases), or show the reproduction.docs/dev/debt/libSceAgcDriver.md:238: this describes the patch, not a known gap; drop it or state the actual open gap (unknown writer of the key).Depends on: noneconflicts with the many open PRs touchingShaderResources.cpp/.hpplisted in the overlap report (see MarcZX10's review); please check ordering with them.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T02:26:08Z.
Review: CHANGES_REQUESTED
Still needs changes; nothing was pushed since the last review and these points need a decision from you, not a mechanical fix:
ShaderResources.cpp:4125-4129:eraseEntryerasesindex.find(it->first)without checkingfound->second == it. A corrupted list key that collides with another live entry removes that entry's mapping and leaves this node's mapping pointing at the freed node. Checkfound->second == itand otherwise take the iterator scan.ShaderResources.cpp:4130-4135: the fallback only runs after the key and the index entry have already diverged, so it hides the corruption instead of removing it, and every miss is an O(n) scan on the eviction path. The root cause in #9497 is still being diagnosed; a fix should either remove the dependence on re-reading the key (e.g. the node holds the map iterator and erases through it) or target the writer once found.docs/dev/debt/libSceAgcDriver.md:260describes the patch, not a known gap. Drop it, or state the open gap (unknown writer of the key).Depends on: noneconflicts with the many open PRs touchingShaderResources.cpp/.hpp; check the ordering and list them.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.