AGC: ResourceCache keeps an index entry for a freed list node (MXGP 26 SIGSEGV in ResourceCache::Find) #9497
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 milescoviello on 2026-10-21T23:25:59Z.
MXGP 26 (PPSA30839) crashed once in 4 runs of the same 900 s menu-to-race route, with SIGSEGV on a GPU queue thread inside
ResourceCache::Find. The core shows the cache's index holding an entry for a list node that had already been freed.Setup:
maina6dcea9279, release libraries, Ubuntu 26.04.1, RTX 4070 Ti, NVIDIA 615.71.09, 12 GB cap, scripted pad input. The crash came 366 s in, between the gamma and profile screens. The other three runs reached the race at 900 s.Stack (queue thread):
It faulted on
mov 0x8(%rdx),%rcxwithrdx = 0x73d900000000, thenextof the nodeFindspliced to the front.What the core shows (gdb, walking
SharedResourceCache()):entriesis intact: 4096 nodes with consistentnext/prevlinks and 4096 distinct keys, each matching itsindexentry.indexhas 4097 entries. The extra one maps a 104-word compute key (starting0, 0, 0x7ac, 0, 3, 1) to0x73d7a80de590. That address is not in the list, and malloc's header marks it as a 32-byte chunk, while a node of this list needs a 64-byte one. It was freed and reused.So one node left
entrieswhile itsindexentry stayed. Every removal inShaderResources.cpperases the index by the node's own key: the capacity loop and the table-element budget loop inInsert,RemoveImage,dropReleasedTextures,eraseandClear, all under the mutex. That leaves two explanations. Either the key stored in that list node changed after insertion, so the eviction'sindex.erase(key)missed, or something outside the cache wrote into it. I found nothing in the class that writes a stored key. That points to a stray write into the key's heap buffer from elsewhere, but I haven't caught the writer.Not done: an AddressSanitizer run of the title (one crash in four runs, about 15 minutes per run). The 4.9 GB core and the relinked
app.elfare on my machine if anyone wants specific values from them.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:31:08Z.
I checked the current
ResourceCacheremoval paths. The list node andunordered_mapeach hold their ownKeyvector copy, and removals callindex.erase(it->first)using the list copy; if that copy is corrupted after insertion,erase(key)can silently miss and leave the map value pointing at the freed list node, matching the extra entry in this core. This does not identify the writer, but it gives a concrete invariant to instrument: compare the map key and list key at insert/removal, or retain the map-entry iterator with the list entry so removal does not depend on re-reading the key. An ASan run of the scripted route would still be the most direct way to locate the overwrite if it reproduces.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T23:37:34Z.
Thanks @MarcZX10, that's the check I'm running now. A local diagnostic build (not a PR) compares each node's list key with its index entry before every by-key erase: the capacity and table-budget evictions,
RemoveImageanddropReleasedTextures.Findalso compares the node's key with the lookup key before the splice. On a mismatch it prints the two copies word by word, with the key buffer's address, and aborts, so the core is taken when the corruption is first seen rather than at the later stale splice. I'll run the scripted MXGP route on it a few times and post the differing words and the overwritten offset here if it fires.AI-assisted: yes (Claude Code)