feat(libkernel): add process and memory lock exports #3650

Closed
MarcZX10 wants to merge 3 commits from upstream-pr/3650 into main
MarcZX10 commented 2026-10-11 14:44:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T14:44:51Z.


What

Carries the three commits from David's ready branch for issue #3628, preserving his authorship. Exports pthread_atfork, mlockall, and getdtablesize so XPSemu and VLC can resolve their imports. Their next startup stops are predicted from registry order and have not been observed in a title run.

  • pthread_atfork records prepare, parent, and child handlers in registration order and returns ENOMEM on allocation failure. Handlers are not run because fork throws and vfork is absent; the limitation is documented in TechnicalDebt.
  • mlockall returns EINVAL for invalid flags and throws for valid requests because locking the whole host process or all future guest and host mappings is not implemented.
  • getdtablesize throws because the console's RLIMIT_NOFILE soft limit and kern.maxfilesperproc are unknown. Returning a guessed limit would cause callers' closefrom loops to close a guessed descriptor range.

Semantics are based on FreeBSD 11.4 (8c639945); the issue body records the source references and title call sites.

Tested

  • Linux, GCC 12.2, Release: built the three affected test targets (guest_pthread_atfork_tests, guest_mlock_tests, guest_getrlimit_tests); CTest passed all three.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD passed.
  • The issue author reports a Windows 11 Pro 26220, WinLibs GCC 15.2.0 Release full build and the new cases passing in the relevant existing tests; see #3628. I did not independently run Windows or a title.

Checklist

  • Based on current main; no other open PR implements these 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
  • 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:4819879249 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3650). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T14:44:51Z. --- ### What Carries the three commits from [David's ready branch](https://github.com/screamm/AnyPS5/tree/feat/libkernel-xpsemu-process) for issue #3628, preserving his authorship. Exports `pthread_atfork`, `mlockall`, and `getdtablesize` so XPSemu and VLC can resolve their imports. Their next startup stops are predicted from registry order and have not been observed in a title run. - `pthread_atfork` records prepare, parent, and child handlers in registration order and returns `ENOMEM` on allocation failure. Handlers are not run because `fork` throws and `vfork` is absent; the limitation is documented in TechnicalDebt. - `mlockall` returns `EINVAL` for invalid flags and throws for valid requests because locking the whole host process or all future guest and host mappings is not implemented. - `getdtablesize` throws because the console's `RLIMIT_NOFILE` soft limit and `kern.maxfilesperproc` are unknown. Returning a guessed limit would cause callers' `closefrom` loops to close a guessed descriptor range. Semantics are based on FreeBSD 11.4 (`8c639945`); the issue body records the source references and title call sites. ### Tested - Linux, GCC 12.2, Release: built the three affected test targets (`guest_pthread_atfork_tests`, `guest_mlock_tests`, `guest_getrlimit_tests`); CTest passed all three. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main...HEAD` passed. - The issue author reports a Windows 11 Pro 26220, WinLibs GCC 15.2.0 Release full build and the new cases passing in the relevant existing tests; see [#3628](https://github.com/boykopovar/AnyPS5/issues/3628). I did not independently run Windows or a title. ### Checklist - [x] Based on current `main`; no other open PR implements these 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 - [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
github-actions[bot] commented 2026-10-11 14:45:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:45:14Z.


Progress report (a11c8f7 → 028c1b4)

📈 System libraries: 85.82% (+0.01%, +3 implemented functions)

✅ 3 implemented
Library Name
libkernel getdtablesize_nid_postfix
libkernel mlockall_nid_postfix
libkernel pthread_atfork_nid_postfix
⚪ 1 behaviourally empty (constant return or throw)
Library Name
libkernel getdtablesize_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110204322 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3650#issuecomment-6110204322). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T14:45:14Z. --- <!-- progress-report --> ### Progress report (a11c8f7 → 028c1b4) 📈 **System libraries**: 85.82% (+0.01%, +3 implemented functions) <details> <summary>✅ 3 implemented</summary> | Library | Name | | - | - | | libkernel | `getdtablesize_nid_postfix` | | libkernel | `mlockall_nid_postfix` | | libkernel | `pthread_atfork_nid_postfix` | </details> <details> <summary>⚪ 1 behaviourally empty (constant return or throw)</summary> | Library | Name | | - | - | | libkernel | `getdtablesize_nid_postfix` | </details>
blawesom commented 2026-10-11 15:19:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:19:43Z.


Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 833/833 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110517172 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3650#issuecomment-6110517172). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T15:19:43Z. --- Independent pre-review on **Linux** (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Builds; `tools/check_conventions.py --base origin/main` passes. - Full suite: **833/833 passed** (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
oneandonlydean commented 2026-10-11 23:58:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:58:26Z.


Closing: getdtablesize always throws, mlockall throws for every valid flag and the pthread_atfork handlers are never run, so no title gets further with this. Reopen when a title stops at one of them on main and the call it makes can be answered.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115347177 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3650#issuecomment-6115347177). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:58:26Z. --- Closing: `getdtablesize` always throws, `mlockall` throws for every valid flag and the `pthread_atfork` handlers are never run, so no title gets further with this. Reopen when a title stops at one of them on main and the call it makes can be answered.

Pull request closed

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!3650
No description provided.