test(libc): cover CRT exit and TLS cleanup lifecycle #9269

Merged
UnhealthyKraken merged 2 commits from upstream-pr/9269 into main 2026-10-26 04:38:22 +00:00
UnhealthyKraken commented 2026-10-21 16:59:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-21T16:59:24Z.


What

Exercise the _Thrd_exit path #8859 left uncalled. Five concurrent guest threads exit with 0, 42, -1, INT_MIN and INT_MAX; the test checks full pointer-width join results, current/equal identities, parent/child TLS isolation, clear-before-destructor behavior and two destructor passes completed before join returns. No runtime implementation changes.

The main refresh adopts the public libc/libkernel declarations and retains the complete existing suite. A volatile function pointer derived from the public exit declaration keeps the post-call nonreturn check reachable without a duplicate local declaration that contradicts the public noreturn annotation.

The _Mtx_current_owns silent-stub debt note retains the contributor-attributed PS5 observation from #8859. The fixture does not establish C++ automatic stack unwinding or concurrent provider-table replacement/unload behavior.

Tested

Review revision 8df45c965d9bbdad708cc771854e5f3331254642, based on main 47f9cee2cd77 by history-preserving merge.

Hosted Linux actual project configure/focused build and the complete guest_libc_threads, guest_pthread_key, guest_execute_once and guest_std_execute_once suites pass 4/4, followed by five repetitions of every suite, using matching source-built libraries. Linux job. Hosted Windows WinLibs GCC 15.2 Release also built matching libraries and passed the complete same four suites, followed by five additional guest_libc_threads repetitions. Windows job. Conventions, whitespace, public-header audit and standalone libc/kernel header compilation pass. Git-only mergeability against later fetched main 504ea3b53b23 is clean; that later combined tree was not built.

Original Windows evidence passed five selected suites with identical baseline/candidate executables; an exit-code sign-extension negative control failed the new assertion. The separate mixed-runtime review report failed the full suite on both head and baseline; it is not counted as a pass or as proof of an introduced regression.

No local builds/runtime tests, games, proprietary modules or physical-console execution were performed for this revision. The full repository suite was not run.

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: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4955290429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9269). Originally posted by [UnhealthyKraken](https://github.com/UnhealthyKraken) on 2026-10-21T16:59:24Z. --- ### What Exercise the `_Thrd_exit` path #8859 left uncalled. Five concurrent guest threads exit with `0`, `42`, `-1`, `INT_MIN` and `INT_MAX`; the test checks full pointer-width join results, current/equal identities, parent/child TLS isolation, clear-before-destructor behavior and two destructor passes completed before join returns. No runtime implementation changes. The main refresh adopts the public libc/libkernel declarations and retains the complete existing suite. A volatile function pointer derived from the public exit declaration keeps the post-call nonreturn check reachable without a duplicate local declaration that contradicts the public noreturn annotation. The `_Mtx_current_owns` silent-stub debt note retains the contributor-attributed PS5 observation from #8859. The fixture does not establish C++ automatic stack unwinding or concurrent provider-table replacement/unload behavior. ### Tested Review revision `8df45c965d9bbdad708cc771854e5f3331254642`, based on main `47f9cee2cd77` by history-preserving merge. Hosted Linux actual project configure/focused build and the complete guest_libc_threads, guest_pthread_key, guest_execute_once and guest_std_execute_once suites pass 4/4, followed by five repetitions of every suite, using matching source-built libraries. [Linux job](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40251248364/job/121343419586). Hosted Windows WinLibs GCC 15.2 Release also built matching libraries and passed the complete same four suites, followed by five additional guest_libc_threads repetitions. [Windows job](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40246759509/job/121339435835). Conventions, whitespace, public-header audit and standalone libc/kernel header compilation pass. Git-only mergeability against later fetched main `504ea3b53b23` is clean; that later combined tree was not built. Original Windows evidence passed five selected suites with identical baseline/candidate executables; an exit-code sign-extension negative control failed the new assertion. The separate mixed-runtime review report failed the full suite on both head and baseline; it is not counted as a pass or as proof of an introduced regression. No local builds/runtime tests, games, proprietary modules or physical-console execution were performed for this revision. The full repository suite was not run. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
THEMANnt commented 2026-10-25 10:58:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T10:58:46Z.

Review: COMMENTED


Reviewed head 65920e6fdc69f88b9d07c12e1568ceac08a6ead1 against d34da5d694cf0803c2986473fa612934150c6708. No actionable code defect verified in the new lifecycle coverage; final approval remains pending merge/conflict resolution and complete matching-runtime validation.

The exact new ThreadExitLifecycle function now executes successfully with matching pinned libc thread-forwarding and libkernel thread/TLS source units, using the repository's Windows target/unwind settings. It verifies five concurrent exit codes (including negative/extreme values), full pointer-width results, identity, parent/child TLS isolation, two destructor passes and key deletion. Existing development DLLs supply ancillary symbols, so this is not a full pinned libc/libkernel DLL rebuild.

The complete GuestLibcThreads suite also builds in that configuration, but both head and original baseline exit with the same exception code 0x20474343 in this mixed-runtime environment. Thus the wider-suite result is not a pass and is not established as an author-introduced regression. The focused lifecycle harness includes the exact author function and calls it alone; its successful result is not presented as a complete-suite result. Earlier head/baseline syntax and repository checks passed.

GitHub currently reports merge conflicts, and hosted native jobs were skipped. Please resolve against current main and rerun the complete target with matching runtime libraries. This formal feedback records the now-verified lifecycle evidence without turning missing validation or conflicts into a fabricated request for changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642836737 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9269#pullrequestreview-5642836737). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-25T10:58:46Z. **Review:** COMMENTED --- Reviewed head `65920e6fdc69f88b9d07c12e1568ceac08a6ead1` against `d34da5d694cf0803c2986473fa612934150c6708`. No actionable code defect verified in the new lifecycle coverage; final approval remains pending merge/conflict resolution and complete matching-runtime validation. The exact new ThreadExitLifecycle function now executes successfully with matching pinned libc thread-forwarding and libkernel thread/TLS source units, using the repository's Windows target/unwind settings. It verifies five concurrent exit codes (including negative/extreme values), full pointer-width results, identity, parent/child TLS isolation, two destructor passes and key deletion. Existing development DLLs supply ancillary symbols, so this is not a full pinned libc/libkernel DLL rebuild. The complete GuestLibcThreads suite also builds in that configuration, but both head and original baseline exit with the same exception code `0x20474343` in this mixed-runtime environment. Thus the wider-suite result is not a pass and is not established as an author-introduced regression. The focused lifecycle harness includes the exact author function and calls it alone; its successful result is not presented as a complete-suite result. Earlier head/baseline syntax and repository checks passed. GitHub currently reports merge conflicts, and hosted native jobs were skipped. Please resolve against current main and rerun the complete target with matching runtime libraries. This formal feedback records the now-verified lifecycle evidence without turning missing validation or conflicts into a fabricated request for changes.
THEMANnt commented 2026-10-26 03:54:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T03:54:52Z.

Review: COMMENTED


Re-reviewed 8df45c965d9bbdad708cc771854e5f3331254642. The merge conflict is resolved; final approval remains pending full-runtime validation.

The expanded lifecycle coverage is consistent with the current thread/TLS implementation. It now runs five concurrent children behind a barrier, checks the full zero-extended exit result for 0, 42, -1, INT_MIN and INT_MAX, verifies identity and parent/child TLS isolation, and verifies two destructor passes plus key deletion. The unrelated libc debt addition explicitly attributes its firmware observation rather than presenting it as independently measured behavior.

Validation: The exact current test passes C++23 syntax compilation. A focused executable including the exact current ThreadExitLifecycle function, matching current Threads/Pthread production units and current project headers passes all of those lifecycle checks. The complete current suite and the original merge-base suite both build in the same harness, but both exit with 0x20474343; the head prints its lifecycle PASS before that later failure. This common failure does not establish a defect introduced by the added lifecycle test.

Scope / next step: The native harness uses repository Windows unwind settings and existing libkernel/libc DLLs for ancillary linkage, rather than complete pinned DLL rebuilds. Obtain a clean full GuestLibcThreads run with matching runtime libraries before the final approval. No request for changes is warranted solely by this review-environment limit, and no full runtime/game pass is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5647174834 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9269#pullrequestreview-5647174834). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-26T03:54:52Z. **Review:** COMMENTED --- Re-reviewed `8df45c965d9bbdad708cc771854e5f3331254642`. The merge conflict is resolved; final approval remains pending full-runtime validation. The expanded lifecycle coverage is consistent with the current thread/TLS implementation. It now runs five concurrent children behind a barrier, checks the full zero-extended exit result for 0, 42, -1, INT_MIN and INT_MAX, verifies identity and parent/child TLS isolation, and verifies two destructor passes plus key deletion. The unrelated libc debt addition explicitly attributes its firmware observation rather than presenting it as independently measured behavior. **Validation:** The exact current test passes C++23 syntax compilation. A focused executable including the exact current ThreadExitLifecycle function, matching current Threads/Pthread production units and current project headers passes all of those lifecycle checks. The complete current suite and the original merge-base suite both build in the same harness, but both exit with 0x20474343; the head prints its lifecycle PASS before that later failure. This common failure does not establish a defect introduced by the added lifecycle test. **Scope / next step:** The native harness uses repository Windows unwind settings and existing libkernel/libc DLLs for ancillary linkage, rather than complete pinned DLL rebuilds. Obtain a clean full GuestLibcThreads run with matching runtime libraries before the final approval. No request for changes is warranted solely by this review-environment limit, and no full runtime/game pass is claimed.
THEMANnt commented 2026-10-26 04:05:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T04:05:38Z.

Review: APPROVED


Re-reviewed 8df45c965d9bbdad708cc771854e5f3331254642. Approve; the earlier validation blocker is resolved.

The pending full-runtime evidence is now verified. The expanded five-child lifecycle checks and the complete existing thread fixture are consistent with the current implementation; the merge conflict remains resolved.

Validation: Independently fetched the author's Windows focused job and Linux focused job logs and job status. Both successful jobs explicitly check out this exact head, build matching libc/libkernel libraries, and pass guest_libc_threads, guest_pthread_key, guest_execute_once and guest_std_execute_once (4/4). Windows additionally passes five thread-suite repetitions; Linux passes five repetitions of all four. The logs include clean tracked-source diff checks. This verifies the specific successful jobs; it does not claim every job in the Windows workflow run succeeded.

Scope: Local exact lifecycle execution also passes. Extending the local source-unit harness with matching mutex/condition/timed-wait code still leaves its later 0x20474343 failure, also seen on the earlier baseline. That mixed-runtime failure is not relabeled as a pass. Approval rests on the independently checked complete source-built hosted runs plus source review, not on a local full-library rebuild. No game/GPU run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5647254037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9269#pullrequestreview-5647254037). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-26T04:05:38Z. **Review:** APPROVED --- Re-reviewed `8df45c965d9bbdad708cc771854e5f3331254642`. Approve; the earlier validation blocker is resolved. The pending full-runtime evidence is now verified. The expanded five-child lifecycle checks and the complete existing thread fixture are consistent with the current implementation; the merge conflict remains resolved. **Validation:** Independently fetched the author's Windows [focused job](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40246759509/job/121339435835) and Linux [focused job](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40251248364/job/121343419586) logs and job status. Both successful jobs explicitly check out this exact head, build matching libc/libkernel libraries, and pass guest_libc_threads, guest_pthread_key, guest_execute_once and guest_std_execute_once (4/4). Windows additionally passes five thread-suite repetitions; Linux passes five repetitions of all four. The logs include clean tracked-source diff checks. This verifies the specific successful jobs; it does not claim every job in the Windows workflow run succeeded. **Scope:** Local exact lifecycle execution also passes. Extending the local source-unit harness with matching mutex/condition/timed-wait code still leaves its later 0x20474343 failure, also seen on the earlier baseline. That mixed-runtime failure is not relabeled as a pass. Approval rests on the independently checked complete source-built hosted runs plus source review, not on a local full-library rebuild. No game/GPU run.
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!9269
No description provided.