Skip to content

test(agc): keep held pipeline gates alive for the jobs that poll them - #20497

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
uttam12331:test/agc-gate-lifetime
Nov 27, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
uttam12331:test/agc-gate-lifetime

Conversation

@uttam12331

Copy link
Copy Markdown
Contributor

What

Three AGC execution tests hold the pipeline with a job that spins on a stack std::atomic<bool> captured by reference, then release it and leave the scope that owns the flag. The worker thread can still be inside the job's next load when the flag's storage goes out of scope, so ASan reports the read on every run, with GCC as well as Clang:

ERROR: AddressSanitizer: stack-use-after-scope on address 0x7d562c200880
READ of size 1 at 0x7d562c200880 thread T23
    #2 in operator() core/libs/prx/libSceAgcDriver/tests/execution/GdsDmaFill.cpp:221:33
Address 0x7d562c200880 is located in stack of thread T0
    [2176, 2177) 'release' (line 218) <== Memory access at offset 2176 is inside this variable

The flag is now a std::shared_ptr<std::atomic<bool>> that the job captures by value, the same fix 7e7ce00 made in PipelinedDma.cpp:

  • GdsDmaFill.cpp: the first held block. The two later blocks call AgcDriverWaitIdle_nid_postfix() before their flag leaves scope and are unchanged.
  • GpuWrittenIndirectBufferQueuedWriter.cpp and PipelinedClockCopy.cpp: Gate owns the shared flag, its destructor still releases it, and the job captures gate.release.

What the tests check is unchanged.

Tested

Ubuntu 24.04, Ninja, Release, -DANYPS5_ENABLE_ASAN=ON -fsanitize=undefined, ASAN_OPTIONS=detect_leaks=0, UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1, main c1dd2b5b50 and this change, ctest --repeat until-fail:10:

Test GCC 13.3.0, main Clang 18.1.3, main GCC 13.3.0, this PR Clang 18.1.3, this PR
agc_driver_gds_dma_fill stack-use-after-scope on release, first run stack-use-after-scope at GdsDmaFill.cpp:221, first run 10/10 pass 10/10 pass
agc_driver_gds_dma_fill_private stack-use-after-scope on release, first run stack-use-after-scope at GdsDmaFill.cpp:221, first run 10/10 pass 10/10 pass
agc_driver_gpu_written_indirect_buffer_queued_writer stack-use-after-scope on gate, first run stack-use-after-scope at GpuWrittenIndirectBufferQueuedWriter.cpp:64, first run 10/10 pass 10/10 pass
agc_driver_pipelined_clock_copy stack-use-after-scope on gate, first run stack-use-after-scope at PipelinedClockCopy.cpp:41, first run 10/10 pass 10/10 pass

Lavapipe (mesa-vulkan-drivers), no GPU.

  • tools/check_conventions.py --base origin/main and git diff --check: clean.
  • tools/pr_overlap.py --branch test/agc-gate-lifetime, against 1,547 open pull requests: no overlap.
  • Not run: Windows, macOS, a hardware GPU, any title.

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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Lavapipe
  • AI-assisted: yes

@github-actions github-actions Bot added the agc libSceAgc* label Nov 15, 2026
@rafaconvaitis

Copy link
Copy Markdown
Contributor

Windows runs on AMD and on NVIDIA (second section); I found neither in the description or in the comments. Head 5c9b721ffa merged alone onto main 3c07e1d05e with git merge --no-ff (clean merge).

Setup: Windows 11 25H2 (build 26200), AMD Radeon 760M integrated graphics (1002:15bf, Vulkan device name Radeon 5), AMD Software 26.11.2 (driver 32.0.32029.2010, Vulkan 1.4.359), selected with ANYPS5_GPU=Radeon, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, Khronos validation layer 1.4.363 (LunarG SDK 1.4.363.1). Only the focused test targets were built; the other execution tests were left out with ANYPS5_AGC_EXECUTION_TESTS.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, ctest -R '^(agc_driver_gds_dma_fill|agc_driver_gds_dma_fill_private|agc_driver_gpu_written_indirect_buffer_queued_writer|agc_driver_pipelined_clock_copy)$' -V -j 1, 3 runs per side.

test main this PR
agc_driver_gds_dma_fill passes 3/3 passes 3/3
agc_driver_gds_dma_fill_private passes 3/3 passes 3/3
agc_driver_gpu_written_indirect_buffer_queued_writer passes 3/3 passes 3/3
agc_driver_pipelined_clock_copy passes 3/3 passes 3/3
  • This PR changes tests only, so there is no negative control to run.
  • VUID- lines: 0 in the main and PR logs. Every run logs Selected GPU name=Radeon 5 vendor=0x1002 device=0x15bf and Insert instance layer "VK_LAYER_KHRONOS_validation", and none logs was not found but was requested.

NVIDIA run, same machine. Head 5c9b721ffa merged alone onto main 66ac8f899e with git merge --no-ff (clean merge).

Setup: Windows 11 25H2 (build 26200), NVIDIA GeForce RTX 3050 6 GB (10de:2584), driver 610.88 (Vulkan 1.4.341), selected with ANYPS5_GPU=NVIDIA, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, Khronos validation layer 1.4.363 (LunarG SDK 1.4.363.1). Only the focused test targets were built; the other execution tests were left out with ANYPS5_AGC_EXECUTION_TESTS.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, ctest -R '^(agc_driver_gds_dma_fill|agc_driver_gds_dma_fill_private|agc_driver_gpu_written_indirect_buffer_queued_writer|agc_driver_pipelined_clock_copy)$' -V -j 1, 3 runs per side.

test main this PR
agc_driver_gds_dma_fill passes 3/3 passes 3/3
agc_driver_gds_dma_fill_private passes 3/3 passes 3/3
agc_driver_gpu_written_indirect_buffer_queued_writer passes 3/3 passes 3/3
agc_driver_pipelined_clock_copy passes 3/3 passes 3/3
  • This PR changes tests only, so there is no negative control to run.
  • VUID- lines: 0 in the main and PR logs. Every run logs Selected GPU name=NVIDIA GeForce RTX 3050 vendor=0x10de device=0x2584 and Insert instance layer "VK_LAYER_KHRONOS_validation", and none logs was not found but was requested.

AI-assisted: yes (build and runs scripted with an AI assistant, on the hardware above).

@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Ran the focused tests with the Khronos validation layer on Linux and an NVIDIA GPU, since CI runs the GPU tests only on lavapipe and the Tested section is lavapipe only.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 5c9b721ffa merged onto main fbaae8a79d with --no-ff (clean, as b4daa05677). Main baseline is a Release build of fbaae8a79d on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_(gds_dma_fill|gds_dma_fill_private|gpu_written_indirect_buffer_queued_writer|pipelined_clock_copy)$' -V
main fbaae8a79d this PR
Result 4 of 4 passed 4 of 4 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 5 5
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

All four tests pass on both sides; every device selected the RTX 4090. This is a plain Release build without ASan, so the stack-use-after-scope from the Tested section does not show on main here; the run only shows the shared-pointer gates change no result and add no validation messages on NVIDIA.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 5c9b721ffa, applied with git apply on main fd4aeed483 together with the other 25 PRs of one batch (#24107, #24132, #24238, #15143, #22088, #22685, #23739, #24032, #16054, #20001, #20344, #24170, #24396, #16856, #17298, #23347, #24426, #24554, #24598, #21376, #21556, #22047, #22082, #14124, #18476). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
agc_driver_gds_dma_fill, agc_driver_gds_dma_fill_private, agc_driver_gpu_written_indirect_buffer and 2 more (5 tests, matched by name to the test file this PR changes) all pass all pass

Whole batch: the full ctest -j 12 (6524 tests) on the RTX 3080 has 8 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #21556 (guest_json_allocator), #16856 (guest_kernel_sys_module_internal), #15143 (guest_math_exact); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): public_headers. The 2127 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants