test(libc): wait for std::async thread teardown in host_thread_local #1604

Merged
Zheorgyan merged 1 commit from upstream-pr/1604 into main 2026-10-10 01:14:22 +00:00
Zheorgyan commented 2026-10-08 14:10:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zheorgyan on 2026-10-08T14:10:08Z.


What

host_thread_local fails about 1 run in 3 on macOS. The std::async block checks the destroyed count right after get(), but libc++ makes the future ready when the task stores its result, before the worker thread runs its thread_local destructors. So the count can still be short by a few when it is checked

the check now waits up to 5 seconds for the 8 destructors before comparing. the block still uses std::async, since that is how the recompiler runs on worker threads, and a missing destructor still fails the test, just after the wait

macOS port: #1

Tested

  • macOS 15.6.1 on an M1 Pro, Apple clang. 188 failures in 500 runs before, 0 in 1000 after. with the expected count changed to 9 the test aborts after the wait, so it still catches destructors that never run
  • Linux, Ubuntu 24.04 in Docker, GCC 14.2. 0 failures in 500 runs, ctest -R host_thread_local passes
  • tools/check_conventions.py passes

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4788077477 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1604). Originally posted by [Zheorgyan](https://github.com/Zheorgyan) on 2026-10-08T14:10:08Z. --- ### What `host_thread_local` fails about 1 run in 3 on macOS. The `std::async` block checks the destroyed count right after `get()`, but libc++ makes the future ready when the task stores its result, before the worker thread runs its `thread_local` destructors. So the count can still be short by a few when it is checked the check now waits up to 5 seconds for the 8 destructors before comparing. the block still uses `std::async`, since that is how the recompiler runs on worker threads, and a missing destructor still fails the test, just after the wait macOS port: #1 ### Tested - macOS 15.6.1 on an M1 Pro, Apple clang. 188 failures in 500 runs before, 0 in 1000 after. with the expected count changed to 9 the test aborts after the wait, so it still catches destructors that never run - Linux, Ubuntu 24.04 in Docker, GCC 14.2. 0 failures in 500 runs, `ctest -R host_thread_local` passes - `tools/check_conventions.py` passes ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
Zheorgyan commented 2026-10-09 08:32:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zheorgyan on 2026-10-09T08:32:52Z.


the upstream run for 688df0b8 is waiting for approval, so I ran the same Build in my fork on that head: https://github.com/Zheorgyan/AnyPS5/actions/runs/37902312975. linux and windows pass

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077389118 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1604#issuecomment-6077389118). Originally posted by [Zheorgyan](https://github.com/Zheorgyan) on 2026-10-09T08:32:52Z. --- the upstream run for `688df0b8` is waiting for approval, so I ran the same Build in my fork on that head: https://github.com/Zheorgyan/AnyPS5/actions/runs/37902312975. linux and windows pass
popcoder565 commented 2026-10-09 15:45:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:45:41Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 688df0b8, merged onto main d70b8998 in one build with 38 other PRs that had no Windows run.

  • This PR's tests pass: host_thread_local. None of them reported skipping a case.
  • Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084259711 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1604#issuecomment-6084259711). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:45:41Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `688df0b8`, merged onto `main` d70b8998 in one build with 38 other PRs that had no Windows run. - This PR's tests pass: `host_thread_local`. None of them reported skipping a case. - Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-10 01:14:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T01:14:19Z.


Checked the wait loop (bounded at 5 s, still aborts if the 8 destructors don't run), local build and host_thread_local pass on Linux, CI green, and popcoder565's native Windows run passes too; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092056107 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1604#issuecomment-6092056107). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T01:14:19Z. --- Checked the wait loop (bounded at 5 s, still aborts if the 8 destructors don't run), local build and `host_thread_local` pass on Linux, CI green, and popcoder565's native Windows run passes too; merging.
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!1604
No description provided.