fix(libkernel): store the process resource limit #8537

Merged
elieh999 merged 2 commits from upstream-pr/8537 into main 2026-10-23 03:44:35 +00:00
elieh999 commented 2026-10-20 15:32:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by elieh999 on 2026-10-20T15:32:30Z.


What

Store RLIMIT_NPROC updates instead of throwing. The requested soft and hard limits are clamped to FreeBSD's 1–1443 range, and later getrlimit calls return the stored values.

This matches the measured PS5 behavior where setting the initial 1604 limit leaves both values at 1443. The focused test now covers the initial value, the upper clamp, the lower clamp, and infinity.

Tested

Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7, Release:

  • guest_setrlimit passed through CTest.
  • python tools/check_conventions.py --base origin/main completed with zero errors.
  • git diff --check origin/main...HEAD passed.
  • python tools/pr_overlap.py --branch fix/setrlimit-nproc completed; manually reviewed its stale-base warnings and found no other open PR implementing setrlimit or RLIMIT_NPROC.

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 (not applicable)
  • 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:4938183644 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8537). Originally posted by [elieh999](https://github.com/elieh999) on 2026-10-20T15:32:30Z. --- ### What Store `RLIMIT_NPROC` updates instead of throwing. The requested soft and hard limits are clamped to FreeBSD's 1–1443 range, and later `getrlimit` calls return the stored values. This matches the measured PS5 behavior where setting the initial 1604 limit leaves both values at 1443. The focused test now covers the initial value, the upper clamp, the lower clamp, and infinity. ### Tested Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7, Release: - `guest_setrlimit` passed through CTest. - `python tools/check_conventions.py --base origin/main` completed with zero errors. - `git diff --check origin/main...HEAD` passed. - `python tools/pr_overlap.py --branch fix/setrlimit-nproc` completed; manually reviewed its stale-base warnings and found no other open PR implementing `setrlimit` or `RLIMIT_NPROC`. ### 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 (not applicable) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
xXPBSXx commented 2026-10-20 22:38:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T22:38:37Z.


Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main 339217ebc9 is clean. I built only guest_setrlimit_tests; ctest -N -R guest_setrlimit lists exactly one test.

Results (3 runs each):

  • PR head: guest_setrlimit passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libkernel/System/src/Process.cpp with its main version, then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's Process.cpp afterwards.

Not run: other platforms, the other process tests, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303355112 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8537#issuecomment-6303355112). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T22:38:37Z. --- Independent Windows run of this PR (data only). **Environment:** Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against `main` 339217ebc9 is clean. I built only `guest_setrlimit_tests`; `ctest -N -R guest_setrlimit` lists exactly one test. **Results (3 runs each):** - PR head: `guest_setrlimit` passes 3/3. - Baseline: I kept the PR's test and replaced only `core/libs/prx/libkernel/System/src/Process.cpp` with its `main` version, then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed `Require`). I restored the PR's `Process.cpp` afterwards. **Not run:** other platforms, the other process tests, the full repository CTest, and any title or console run. AI-assisted (Claude Code).
xXPBSXx commented 2026-10-21 09:45:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T09:45:18Z.


Linux data point for bb396009e0: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, BUILD_TESTING=ON, PR head alone (not merged onto main).

  • With the PR: ctest -R '^guest_setrlimit$' passes 3 of 3.
  • With core/libs/prx/libkernel/System/src/Process.cpp restored to the merge-base (new test kept): fails (Subprocess aborted).
    Not tested: macOS, Windows, a title run.
    AI-assisted (Claude Code).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312961960 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8537#issuecomment-6312961960). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T09:45:18Z. --- Linux data point for `bb396009e0`: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release, `BUILD_TESTING=ON`, PR head alone (not merged onto `main`). - With the PR: `ctest -R '^guest_setrlimit$'` passes 3 of 3. - With `core/libs/prx/libkernel/System/src/Process.cpp` restored to the merge-base (new test kept): fails (`Subprocess aborted`). Not tested: macOS, Windows, a title run. AI-assisted (Claude Code).
EagleBearerYS commented 2026-10-22 05:38:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T05:38:49Z.


@elieh999 a merge-order note: #9477 adds an entry to docs/dev/debt/libkernel.md a few lines below the setrlimit entry this PR edits, and the two conflict in that file only. Their code doesn't meet. Neither needs to wait for the other: if this PR merges first, #9477 rebases and keeps your entry, and if #9477 merges first, I can put the resolved file on a branch of my fork for you to take.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333625221 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8537#issuecomment-6333625221). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T05:38:49Z. --- @elieh999 a merge-order note: #9477 adds an entry to `docs/dev/debt/libkernel.md` a few lines below the `setrlimit` entry this PR edits, and the two conflict in that file only. Their code doesn't meet. Neither needs to wait for the other: if this PR merges first, #9477 rebases and keeps your entry, and if #9477 merges first, I can put the resolved file on a branch of my fork for you to take.
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!8537
No description provided.