Skip to content

test(agc): shut libc down before agc_shader_helpers returns - #6925

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
LeandroLP23:fix/agc-shader-helpers-shutdown
Oct 17, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
LeandroLP23:fix/agc-shader-helpers-shutdown

Conversation

@LeandroLP23

@LeandroLP23 LeandroLP23 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes #6791. On Windows, agc_shader_helpers returned from main with the driver's threads still running. ExitProcess ends those threads first, then the DLLs' static destructors run at DLL_PROCESS_DETACH and wait forever on what the threads left locked. The test prints shader helper preparation tests passed and then never exits.

With debug info (-O3 -g) and gdb -p on hung processes, the main thread is the only thread left. It waits in one of three places, and a fix for one moves the hang to the next:

Where the main thread waits Seen
AsyncLog::Flush (unique_lock on the queue mutex), inlined into Driver::stop from ~Driver on main. The mutex sits at offset 8 of AsyncLog, the lea 0x8(%rax),%rcx in #6791's disassembly
~DeviceUseGate (its condition_variable), from ~Driver after stop returns 9 of 9 hangs with Driver::stop's flush bounded
_execute_onexit_table of libkernel.prx, in a libstdc++ destructor that waits in winpthreads 5 of 5 hangs with the Driver also kept alive at detach

So the cause is the test's exit path, not one lock. The other driver tests (PipelinedDma, PipelinedDispatch, DepthFastClearSubmit, ...) already call LibcRunShutdown_nid_postfix before they return, which stops the driver while its threads are still alive. agc_shader_helpers now does the same, on success and on failure.

#6817 bounds the same test's runtime with a CTest TIMEOUT; the two don't overlap.

Tested

Windows 11 (26300), Radeon 860M (RDNA 3.5, 1002:1114, driver 32.0.13058.8001), WinLibs GCC 15.2.0, ctest -R '^agc_shader_helpers$' --timeout 30, one test per ctest process:

Tree Runs Timed out
main 82ddae75b, Release 27 9
main 82ddae75b, -O3 -g 30 4
this change, -O3 -g (same build) 60 0

Not tested: macOS.

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
  • Unblocks: none (main's Windows CI)
  • GPUs tested: AMD Radeon 860M (RDNA 3.5), driver 32.0.13058.8001, Windows 11
  • AI-assisted: yes (Claude Code)

On Windows, agc_shader_helpers returned from main with the driver's
threads still running. ExitProcess ends them first, then the DLLs'
static destructors run and wait on what those threads left locked:
the async log's queue mutex in Driver::stop, DeviceUseGate's condition
variable in ~Driver, and condition variables in libkernel's statics.
The test hung after printing its result in about one ctest run of
three on a Radeon 860M (boykopovar#6791).

Like the other driver tests, it now runs LibcRunShutdown_nid_postfix
before returning, which stops the driver while its threads are alive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarcZX10

Copy link
Copy Markdown
Contributor

I reviewed the shutdown calls against the existing AGC test pattern on current main. Running LibcRunShutdown_nid_postfix() on success and best-effort from the exception path matches the neighboring driver tests and addresses the reported DLL-detach deadlock path. The issue records the 60/60 Windows post-fix runs; hosted conventions, eligibility, intake and report checks pass here, while the platform/build jobs are skipped. I have no code change to request from this review.

@oneandonlydean
oneandonlydean merged commit 16c607a into boykopovar:main Oct 17, 2026
10 checks passed
@LeandroLP23
LeandroLP23 deleted the fix/agc-shader-helpers-shutdown branch October 22, 2026 13:05
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.

Windows: agc_shader_helpers intermittently hangs at exit in Driver::stop() under ctest

3 participants