AGC tests: request memory spans outlive temporary Regions() vectors #7754
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 Amoenus on 2026-10-19T05:59:42Z.
Observed on main
At
46f27623c28b237f6b7dab93862a318e4977cc19,ShaderMemory.cppcontains 20 assignments of a temporaryShaderMemory::Regions()result to a request's borrowedcontext.memoryspan. Representative sites are the out-of-range buffer-load fixture and the guarded-image store lambda.ShaderMemory::Regions()returnsstd::vector<ShaderRecompiler::MemoryRegion>by value (declaration);GuestContext::memoryisstd::span<const MemoryRegion>(definition). The temporary vector is destroyed at the assignment's semicolon, before the followingRecompilecall can use or serialize the request. Keeping theShaderMemoryobject alive does not retain the returned vector's region records.Existing related evidence
This is the same test-lifetime pattern identified and corrected at one site in #757. That report describes a Linux failure during expected-error request serialization. The remaining sites above still exist after that PR merged; this is a report of those remaining instances, not a duplicate of its feature work.
Cppcheck 2.20 reports
danglingTemporaryLifetimeat the first two sites and several others in our current analysis; clang-tidy 23.1.3 also reports lifetime diagnostics in the same translation unit. The analysis used actual Windows build commands, with no parser/configuration errors or timeouts. Our analyzed integration is689c0eae0eb7b12a3599b782ba87db5b53789ac6on main9f5d4bd929; the patterns and return/member types were separately verified against the exact current-main SHA above before filing.Proposed correction
Active upstream fix: #7759 by @MarcZX10. It repairs these 20 sites and the additional image-table helper. Our independent exact-head validation records successful Windows/Linux builds and 20 fresh-process CPU passes (both affected fixtures, five repetitions per OS). Cppcheck and clang-tidy complete for both changed translation units with no remaining dangling-span diagnostics; unrelated advisories remain.
Our earlier one-file prototype is preserved as e3b870798, with its mainfeb adaptation. No duplicate upstream PR will be submitted.
Keep the returned region vector alive through every consumer of the request, following the existing repair in #757. For a single call:
For reused requests and lambdas, keep ownership across subsequent capture/recompile calls or use a local request copy so an outer request does not retain a view after its owner dies. Each scope needs inspection; replacing the assignment mechanically is insufficient.
Validation limits
This is a test-correctness finding confirmed from the C++ ownership/types and analyzer diagnostics. No production API change, game unblock or newly reproduced title crash is claimed. ASan does not pass: unmodified main46f and our e3b prototype abort earlier in SPIRV-Tools /
std::stable_sortwith an allocator mismatch, separately reported as #7765. We did not suppress that check, and these sanitizer runs are not exact-head #7759 validation. Uninstrumented passes alone do not prove the former dangling accesses were safe. The allocator issue has since been fixed upstream by #7781; a full combined-fixture ASan rerun is pending here. Earlier pinned ASan failures remain historical results.AI-assisted investigation/report: yes, Codex.