feat(libkernel): implement pthread_atfork registration #4377

Merged
MarcZX10 merged 2 commits from upstream-pr/4377 into main 2026-10-13 16:54:55 +00:00
MarcZX10 commented 2026-10-12 08:14:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T08:14:39Z.


What

Carries the pthread_atfork implementation from #3628, preserving its original commit author. It records prepare/parent/child handlers in registration order and returns ENOMEM on allocation failure. Null handlers are accepted. Since fork is not implemented, registered handlers do not run; unload-time removal is also not modeled, and both limits are documented in docs/dev/debt/libkernel.md.

Tested

  • Before this current-main rebase, Windows 10 MinGW GCC passed guest_pthread_atfork; a Linux rebase handoff reported the full suite passing.
  • The current-main rebase has not been built or tested locally. CI/reviewer validation should rerun against this head.

Current title evidence

PPSA97358 has a source-level pthread_atfork call, but a current-main run has not shown it as the active unresolved import. XPSemu's verified first stop is mlockall (#4386). No title-unblocks claim is made until a run records pthread_atfork as the next stop after the earlier imports are resolved.

Checklist

  • Based on current main; no other open PR implements this function
  • One topic: pthread_atfork
  • No comments in code except technical debt
  • No notes or investigation files added
  • Generic behavior, not title-specific
  • Depends on: none
  • AI-assisted: yes; original implementation author preserved
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4826703958 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T08:14:39Z. --- ### What Carries the `pthread_atfork` implementation from #3628, preserving its original commit author. It records prepare/parent/child handlers in registration order and returns `ENOMEM` on allocation failure. Null handlers are accepted. Since `fork` is not implemented, registered handlers do not run; unload-time removal is also not modeled, and both limits are documented in `docs/dev/debt/libkernel.md`. ### Tested - Before this current-main rebase, Windows 10 MinGW GCC passed `guest_pthread_atfork`; a Linux rebase handoff reported the full suite passing. - The current-main rebase has not been built or tested locally. CI/reviewer validation should rerun against this head. ### Current title evidence PPSA97358 has a source-level `pthread_atfork` call, but a current-main run has not shown it as the active unresolved import. XPSemu's verified first stop is `mlockall` (#4386). No title-unblocks claim is made until a run records `pthread_atfork` as the next stop after the earlier imports are resolved. ### Checklist - [x] Based on current `main`; no other open PR implements this function - [x] One topic: `pthread_atfork` - [x] No comments in code except technical debt - [x] No notes or investigation files added - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] AI-assisted: yes; original implementation author preserved
github-actions[bot] commented 2026-10-12 08:28:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T08:28:04Z.


Progress report (6d7b873 → 8d455b8)

➖ System libraries: 87.79% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel pthread_atfork_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120576630 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6120576630). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T08:28:04Z. --- <!-- progress-report --> ### Progress report (6d7b873 → 8d455b8) ➖ **System libraries**: 87.79% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `pthread_atfork_nid_postfix` | </details>
xXPBSXx commented 2026-10-12 11:51:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T11:51:14Z.


Windows test: head 7a510b61c merged onto current main 3d8ffeb27 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j4: full build 0 errors; ctest with the filter guest_pthread_atfork: guest_pthread_atfork passed (1 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6123694501 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6123694501). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T11:51:14Z. --- Windows test: head `7a510b61c` merged onto current `main` `3d8ffeb27` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j4`: full build 0 errors; ctest with the filter `guest_pthread_atfork`: guest_pthread_atfork passed (1 test(s), 0 failed); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
blawesom commented 2026-10-12 14:02:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T14:02:03Z.


Rebase handoff — rebased onto current main, authorship unchanged (only a TechnicalDebt.md union conflict; both entries kept).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 954/954 passed

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4377
git checkout <your branch>
git merge --ff-only FETCH_HEAD
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6125842386 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6125842386). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-12T14:02:03Z. --- **Rebase handoff** — rebased onto current `main`, authorship unchanged (only a `TechnicalDebt.md` union conflict; both entries kept). Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 954/954 passed** **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4377 git checkout <your branch> git merge --ff-only FETCH_HEAD ```
oneandonlydean commented 2026-10-13 00:19:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:19:38Z.


#3980 (setrlimit) is merged. Does PPSA97358 now stop at U9t5kJAWPnA on main? With that log line this can go in. The rebase needs redoing first: it deletes the sceAgcDcbSetWorkloadsActive entry from docs/dev/debt/libSceAgc.md, adds the kern.arandom line to docs/dev/debt/libkernel.md a second time, and conflicts with main in both files.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135168832 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6135168832). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T00:19:38Z. --- #3980 (`setrlimit`) is merged. Does PPSA97358 now stop at `U9t5kJAWPnA` on main? With that log line this can go in. The rebase needs redoing first: it deletes the `sceAgcDcbSetWorkloadsActive` entry from `docs/dev/debt/libSceAgc.md`, adds the `kern.arandom` line to `docs/dev/debt/libkernel.md` a second time, and conflicts with main in both files.
MarcZX10 commented 2026-10-13 07:13:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:13:33Z.


I do not have a runtime log showing PPSA97358 reaches pthread_atfork after #3980. The separate XPSemu report on #4386 establishes an mlockall import stop, not an atfork call, and the original #3628 report described these stops as predictions. I will not claim title validation for this PR without that log; the PR still needs the requested rebase and current-main evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140339735 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6140339735). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:13:33Z. --- I do not have a runtime log showing PPSA97358 reaches pthread_atfork after #3980. The separate XPSemu report on #4386 establishes an mlockall import stop, not an atfork call, and the original #3628 report described these stops as predictions. I will not claim title validation for this PR without that log; the PR still needs the requested rebase and current-main evidence.
MarcZX10 commented 2026-10-13 07:39:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:39:43Z.


Not yet. The current-main XPSemu run cited on #4386 stops first at the unresolved mlockall import; its separate pthread_atfork call site has not been shown to execute or become the next unresolved import. I rebased this PR onto current main, kept the existing AGC debt entries, removed the duplicate kern.arandom line, and updated the atfork debt note and PR description to distinguish source-level presence from runtime reachability. The older test reports predate this rebase, so this head still needs CI and a title rerun after the earlier stop is resolved.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140735876 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6140735876). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:39:43Z. --- Not yet. The current-main XPSemu run cited on #4386 stops first at the unresolved `mlockall` import; its separate `pthread_atfork` call site has not been shown to execute or become the next unresolved import. I rebased this PR onto current `main`, kept the existing AGC debt entries, removed the duplicate `kern.arandom` line, and updated the atfork debt note and PR description to distinguish source-level presence from runtime reachability. The older test reports predate this rebase, so this head still needs CI and a title rerun after the earlier stop is resolved.
p3n1cillin commented 2026-10-13 14:10:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T14:10:55Z.


Title run with this PR: Windows 11, MinGW GCC 15.2.0 (WinLibs), Release. Built on main 3faa9cb40 merged with this PR and the other open PRs that the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4863, #4105, my #5013/#5061/#5078/#5098/#5009 and the carries #5183/#5186, plus screamm's chroot branch from #3632); every title converted from its catalog release, eboot.bin kept in app0, 60 s runs.

  • XPSemu (PPSA97358): with this PR, #4105 and #5061 (mlockall and posix_spawn are merged), tools/import_audit.py lists no absent import and it loads. It then stops on getrlimit: unsupported resource 8 in QEMU's os_setup_limits (#5187), and after that on the fixed 0x400000 GOT read that #4013 tracks.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147493379 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6147493379). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T14:10:55Z. --- Title run with this PR: Windows 11, MinGW GCC 15.2.0 (WinLibs), Release. Built on `main` `3faa9cb40` merged with this PR and the other open PRs that the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4863, #4105, my #5013/#5061/#5078/#5098/#5009 and the carries #5183/#5186, plus screamm's `chroot` branch from #3632); every title converted from its catalog release, `eboot.bin` kept in `app0`, 60 s runs. - XPSemu (PPSA97358): with this PR, #4105 and #5061 (`mlockall` and `posix_spawn` are merged), `tools/import_audit.py` lists no absent import and it loads. It then stops on `getrlimit: unsupported resource 8` in QEMU's `os_setup_limits` (#5187), and after that on the fixed 0x400000 GOT read that #4013 tracks. AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-13 15:06:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T15:06:38Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4725 docs/dev/debt/libkernel.md L168-169
#5275 docs/dev/debt/libkernel.md L168
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148638024 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4377#issuecomment-6148638024). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T15:06:38Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4725 | `docs/dev/debt/libkernel.md` [L168-169](https://github.com/boykopovar/AnyPS5/blob/0214069e33ccfab4bd97ec973637299895f786d0/docs/dev/debt/libkernel.md#L168-L169) | | | | #5275 | `docs/dev/debt/libkernel.md` [L168](https://github.com/boykopovar/AnyPS5/blob/0214069e33ccfab4bd97ec973637299895f786d0/docs/dev/debt/libkernel.md#L168) | | |
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!4377
No description provided.