fix(agc): reject a chained INDIRECT_BUFFER that revisits a buffer of its chain #22572
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22572"
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 Jazeupoi on 2026-11-17T21:49:32Z.
What
A chained
INDIRECT_BUFFERthat leads back to a buffer already copied in the same chain was rejected only when the1 << 26word copy budget ran out. For the 4-word self-link inagc_driverthat is about 16.7 million passes, and on Windows the test took 24 to 123 s (#22565).Driver::copySegmentnow compares each chained target (address and size) with a marked link. The mark moves to the current link after 1, 2, 4, 8, ... links (Brent's cycle detection). A chain that revisits one of its buffers is rejected after a few passes over the loop, witha chained indirect buffer leads back to a buffer of its own chain (a jump loop). The self-link and pair checks look for that text, so they fail onmain, where the loop still ends at the copy limit. It uses no memory per link, and the budget is unchanged, so long chains that end are copied as before. As discussed in #22565, this rejects the revisited link and keeps the budget.The test adds two buffers that chain to each other next to the existing self-link check.
#22441 and #22434 add a parameter to the
copyLinkcall in the samecopySegmentloop. Neither changes how a loop is detected, so whichever is merged later needs only a small rebase.Tested
agc_driver, Release,mainand this change on the same machine.Windows 11 Pro, AMD Ryzen 5 3400G, NVIDIA GeForce RTX 2060 (driver 621.24), WinLibs GCC 15.2.0.
mainbef2f1f77dwith #22373 merged, because the full Windows test build stops on #22358.mainmacOS 27.0.1, Apple M4, MoltenVK (Vulkan SDK 1.4.363), x86-64 Release under Rosetta 2.
maine798a424c7with #17425 and #11049;Submission.cppandSubmit.cppare the same as inbef2f1f77d.mainValidation, 3 runs of
ctest -V -R '^agc_driver$'onmainand on this change on each machine, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, validation layer 1.4.363. Every log showsInsert instance layer "VK_LAYER_KHRONOS_validation", none showswas not found but was requested by env var VK_INSTANCE_LAYERS, and none has aVUID-line, onmainor on this change.agc_driverpassed in every run. With the layer, the test took:mainThe tables are for
8164e0627b.ca7c91789bchanges only the error text and the two checks. On the Mac: 3 runs ofagc_driverpassed (15.0, 11.5 and 11.4 s), and 3 validation runs passed with the layer inserted and noVUID-line. One more validation run hung at device start, in the float-controls probe, beforetestValidationandtestChainedIndirectBuffersrun. With only the newSubmit.cpponmain's driver,agc_driverfails witha chained indirect buffer that links to itself was not rejected as a jump loop.python3 tools/check_conventions.pypasses.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-17T22:44:33Z.
Review: COMMENTED
I read this against
main9f75bf0be3. I didn't build it, since a title run holds the host right now.The detection looks right to me:
copySegmentcall. A nested (non-chained)INDIRECT_BUFFERthat calls the same buffer twice, for example a shared state block, still goes throughcopyLink's recursion with its own mark, so that legal pattern isn't touched.mainended the same way, just 2^26 words later, so no chain thatmaincopies to the end is rejected now.One optional point: the new
requiresays "command buffer jumps exceed the copy limit" when no limit was reached. Something like "a chained indirect buffer leads back to a buffer of its own chain (a jump loop)" would say what happened. The self-link and pair checks could then look for that text. The 2000-link chain stays the check that a long chain that ends is still copied.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-18T14:39:12Z.
Review: APPROVED
Re-read at
ca7c91789b. Therequirenow names the jump loop, and both the self-link and the pair checks look for that text, so they can no longer pass onmain's copy-limit stop. domx4q's negative control above (this PR's test withmain'sSubmission.cpp, failing 2 of 2) shows that. Nothing else changed since my read of8164e0627b. Looks good to me.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T07:36:35Z.
Review: APPROVED
Reviewed — looks good
The cycle check appears correct for chained INDIRECT_BUFFER loops, and the changed tests cover self-links, two-buffer cycles, and a long terminating chain.
What I ran
Reviewed head
ca7c91789b7128674564619041e54830224ba617using the pinnedrepo_read.pyreader. I readreview/description.md,review/commits.md,review/manifest.json,review/diff.patch, and the relevant ranges in both changed files. No tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported Windows and macOS test runs and convention check were not independently verified. No other files were changed according to the manifest; both changed files were read in relevant ranges, not in full.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T13:17:43Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
64be018763c6ed12a84ce521e602bc8d8c2ebbad. I read the prepared description, commits, manifest, diff, and both changed files’ relevant ranges throughrepo_read.py; I did not run commands or tests.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read
Submission.cpplines 205–255 and 260–340, andSubmit.cpplines 140–190. Both files listed in the manifest as reviewed were read in the relevant ranges, but neither full file was read. Runtime behavior and author-reported test results were not independently verified.files.jsonwas not available in the review bundle, so excluded files could not be confirmed.To get this to a good state
Nothing is required.