fix(agc): bound the async log's exit flush #6800

Merged
adriadam10 merged 1 commit from upstream-pr/6800 into main 2026-10-16 12:30:35 +00:00
adriadam10 commented 2026-10-16 12:30:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T12:30:29Z.


What

Main fix. AsyncLog (#6371) registers std::atexit([] { Get().Flush(); }), an unbounded wait for the logger thread. libSceAgcDriver is a DLL on Windows, and a DLL's atexit handlers run at DLL_PROCESS_DETACH, after ExitProcess has ended every other thread. If lines are still queued then, the logger thread is gone and Flush waits forever. guest_shader_link on Windows either passes in ~0.03 s or times out at 120 s. It timed out on 4 of the last 7 completed main push builds (38885843235, 38892071250, 38892996281, 38896166619), all after #6371, and never before. The handler now runs FlushAtEnd, the bounded flush (FlushFor, 2 s, lock-free) that AsyncLog already registers for abort, terminate and _Exit. docs/dev/ARCHITECTURE.md now says which flush runs at exit and why.

Tested

Linux: the header compiles (g++ -std=c++20 -fsyntax-only on tests/AsyncLog.cpp). Windows can't be run here. Merged as a quick main fix without the full Build; main's next Windows push builds are the proof. Because the hang is intermittent, the proof is guest_shader_link green on several consecutive Windows builds, not just one.

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
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4888386303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6800). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T12:30:29Z. --- ### What Main fix. `AsyncLog` (#6371) registers `std::atexit([] { Get().Flush(); })`, an unbounded wait for the logger thread. `libSceAgcDriver` is a DLL on Windows, and a DLL's `atexit` handlers run at `DLL_PROCESS_DETACH`, after `ExitProcess` has ended every other thread. If lines are still queued then, the logger thread is gone and `Flush` waits forever. `guest_shader_link` on Windows either passes in ~0.03 s or times out at 120 s. It timed out on 4 of the last 7 completed main push builds (38885843235, 38892071250, 38892996281, 38896166619), all after #6371, and never before. The handler now runs `FlushAtEnd`, the bounded flush (`FlushFor`, 2 s, lock-free) that `AsyncLog` already registers for `abort`, `terminate` and `_Exit`. `docs/dev/ARCHITECTURE.md` now says which flush runs at exit and why. ### Tested Linux: the header compiles (`g++ -std=c++20 -fsyntax-only` on `tests/AsyncLog.cpp`). Windows can't be run here. Merged as a quick main fix without the full Build; main's next Windows push builds are the proof. Because the hang is intermittent, the proof is `guest_shader_link` green on several consecutive Windows builds, not just one. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6800
No description provided.