Skip to content

fix(agc): stop capture tracing before driver unload - #19324

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
lgqdaxia:codex/fix-capture-trace-shutdown-20261113
Nov 16, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
lgqdaxia:codex/fix-capture-trace-shutdown-20261113

Conversation

@lgqdaxia

Copy link
Copy Markdown
Contributor

What

With capture tracing enabled on Windows, a completed replay can hang while its DLL is unloaded: CaptureTrace joins its writer from a static destructor under the loader lock.

Stop and drain the trace during normal driver shutdown, after its producers have stopped. The later destructor reuses that completed stop. Repeated/concurrent stops are safe, unused tracing stays unused, and late records cannot restart the writer.

Tested

Windows x64, MinGW GCC 15.2 / UCRT: 21 focused CaptureTrace cases passed, including queued-record preservation, repeated/concurrent stop, write/flush failure handling and DLL unload. The final DLL fixture also builds and passes its unload test with the project's -fno-asynchronous-unwind-tables setting and libc linkage.

The current-main DLL reproducer hangs during explicit unload and ordinary process exit; stopping the candidate first lets both finish, preserving all 32 queued records and one summary. Reproduction commands and waiting stacks are described in #19321. Conventions and diff checks pass.

Validation setup — 2026-11-13

Base: a6606d5bab753def2a088d412795039a8f71e076. CPU-only logging/lifecycle tests, using the actual CaptureTrace sources and test-registration fragment in a focused Ninja configuration with an existing source-built libc. All three CaptureTrace test executables are registered as run. The standalone process-exit harness returns normally with exit code 0.

pr_overlap.py required manual comparison of the shared Lifecycle.cpp changes in #5925, #6188, #11435, #11436, #15136, #15456 and #18293. Those changes concern other workers, recorder waits or the arm gate; none stops CaptureTrace or creates a landing dependency for this fix.

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: Fixes CaptureTrace can hang on Windows DLL unload after replay completes #19321
  • Unblocks: none
  • GPUs tested: n/a (CPU-only logging/lifecycle)
  • AI-assisted: yes

@github-actions github-actions Bot added build agc libSceAgc* labels Nov 13, 2026
@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 36a9e9772f, merged onto main 04202b49a5 (merge cb6ca9cf2a). Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

All 21 agc_capture_trace_* tests pass in 3 of 3 runs, including the new dll_shutdown, stop_unused and stop_drains:

  • 17 tests through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1: the binaries matched the hashes recorded at preparation, and the receipt shows exit 0 and app_count=0.
  • The other 4, write_failure, flush_failure and their _runtime runs, failed in that FIFO run with no such file or directory. My target list had not built their fixture executables, agc_capture_trace_failure_tests and agc_capture_trace_runtime_failure_tests. After building both in the same build tree, all 4 passed in 3 of 3 runs, on the CPU with Vulkan hidden.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
PR 11435 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
PR 11436 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
PR 15456 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp
PR 16791 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp

@NathanFahey23

Copy link
Copy Markdown
Contributor

Windows NVIDIA check of head 36a9e9772f, merged onto main a6606d5bab (adbcd3123d, clean merge).

Setup: Windows 11 Home 10.0.26300, i9-13900K, WinLibs GCC 15.2.0, Release, RTX 4080 (10de:2704, driver 32.0.16.2101), ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, Vulkan validation layer on.

ctest -R '^(agc_|shader|video_out|guest_video)' --parallel 4:

passed validation errors
main a6606d5bab 1736/1736 0
with this PR 1739/1739 0

The three extra tests are the ones this PR adds to that set; they pass.

Not checked: whether the new tests fail on main without the fix, the rest of the suite, real titles.

AI-assisted: yes

@github-actions github-actions Bot added the fix error Closes an issue (Fixes #N) label Nov 13, 2026
@Kal0s-design

Copy link
Copy Markdown

Check of head 36a9e9772f, merged onto main 78276498ec (clean merge). It adds the two things the earlier checks left open: whether the unload test fails without the stop, and a sanitizer run of the concurrent stop.

Windows, WinLibs GCC 15, Release

  • All 21 agc_capture_trace_* tests pass in 10 of 10 runs.
  • agc_capture_trace_dll_shutdown is sensitive to the fix. With the two stop() calls removed from DllShutdown in a local copy of the test, so the DLL is unloaded with its writer still running, it times out at 15 s in 5 of 5 runs. With the calls restored it passes in 0.07 s.

Linux 6.18, GCC 16, Release. The 20 agc_capture_trace_* tests registered there, 20 runs each:

Build Result
plain 20 of 20
ASan + UBSan 20 of 20
TSan 20 of 20, no report, including stop_drains with its four concurrent Stop() callers

Not covered: the two-line call in Lifecycle.cpp during a real driver shutdown or replay, GPU tests, macOS.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit 53a07dc into boykopovar:main Nov 16, 2026
14 checks passed
@lgqdaxia
lgqdaxia deleted the codex/fix-capture-trace-shutdown-20261113 branch November 28, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build fix error Closes an issue (Fixes #N)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CaptureTrace can hang on Windows DLL unload after replay completes

5 participants