Skip to content

feat(libkernel): answer getrlimit for FreeBSD resources - #3765

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
pushkarreddyy:feat/libkernel-wait-rlimits
Oct 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
pushkarreddyy:feat/libkernel-wait-rlimits

Conversation

@pushkarreddyy

@pushkarreddyy pushkarreddyy commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What

This pull request implements FreeBSD 11 process-0 baseline resource limits in getrlimit within libkernel:

  • getrlimit(resource, limit):
    • Populates RLIM_INFINITY (

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The getrlimit part checks out: the nine values match FreeBSD 11.4 proc0_init (sys/kern/init_main.c, all limits start at RLIM_INFINITY; only NOFILE/NPROC/DATA/STACK/RSS/MEMLOCK are overridden, and those are the ones you keep throwing). Tests pass locally and fail without the change.

One blocker:

  • wait (Process.cpp:293, GuestWaitpid.cpp:14-23, the wait and waitpid TechnicalDebt line) is already implemented by the open #3715 (same forwarding to waitpid(-1, status, 0), same test), opened earlier. CONTRIBUTING doesn't allow two open PRs implementing the same function.

Please drop the wait parts and keep this PR to getrlimit (restore the original waitpid TechnicalDebt line, add only the getrlimit one, and update the title/body, with "Depends on: none"). It can then be merged independently of #3715.

@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Implementation Details & Expedited Testing Request

Hi @adriadam10, @MarcZX100, @blawesom,

This PR directly addresses the start-up crashes across PS5MC (PPSA99420), XPSemu (PPSA97358), and VLC (PPSA85300) as reported in #3733:

  1. wait(status) (ldVb3lc75PE):

    • wait was completely missing from libkernel, causing PS5MC (PPSA99420) to halt immediately on dynamic relocation (FAIL: unresolved ELF import ldVb3lc75PE from libkernel.prx).
    • Implemented by delegating directly to waitpid(-1, status, 0). When no children exist, it preserves the caller's status buffer and returns -1 with errno = ECHILD (10), matching FreeBSD 11.4 lib/libc/gen/wait.c (8c639945).
  2. getrlimit Process-0 FreeBSD Baseline Defaults:

    • Previously hard-threw getrlimit: unsupported resource on every resource other than RLIMIT_DATA (2).
    • PS5MC (PPSA99420) queries RLIMIT_CORE (4) at 7 call sites during its initialization (what(): getrlimit: unsupported resource 4).
    • Extended to report RLIM_INFINITY (

@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-wait-rlimits branch from 060a4a2 to 13fc1fe Compare October 11, 2026 16:46
@pushkarreddyy pushkarreddyy changed the title feat(libkernel): implement wait and answer getrlimit for FreeBSD resources feat(libkernel): answer getrlimit for FreeBSD resources Oct 11, 2026
@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Clean Scope Update

To maintain strict one-topic focus and avoid any duplicate export collisions with @Lorkydey's PR #3715 (which exports wait), this PR has been narrowed purely to getrlimit ( eat(libkernel): answer getrlimit for FreeBSD resources):

  • Answers the 9 process-0 FreeBSD baseline resource limits (RLIMIT_CPU, FSIZE, CORE, SBSIZE, VMEM/AS, NPTS, SWAP, KQUEUES, UMTXP).
  • Resolves the 7 RLIMIT_CORE abort sites in PS5MC (PPSA99420), XPSemu (PPSA97358) limit queries, and VLC (PPSA85300) RLIMIT_AS queries.
  • Zero collision or overlap with PR feat(libkernel): implement wait through guest waitpid #3715 or any open PR.
  • Both PRs can merge independently and cleanly.

@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Hi @adriadam10,

Thank you for the review and confirmation on the FreeBSD 11.4 proc0_init values!

I have addressed the blocker exactly as requested:

  1. Dropped wait completely: Removed wait_nid_postfix from Process.cpp and restored GuestWaitpid.cpp to main.
  2. Restored TechnicalDebt: Preserved the original waitpid line in docs/dev/TechnicalDebt.md untouched, and added only the getrlimit functional debt line.
  3. Dedicated Scope: Updated the PR title to eat(libkernel): answer getrlimit for FreeBSD resources and the body with Depends on: none, keeping this PR 100% focused on getrlimit so it merges independently of feat(libkernel): implement wait through guest waitpid #3715.
  4. CI & Conventions: Conventions passed with 0 comments in C++ source files, and unit tests in guest_getrlimit pass.

Ready for re-review and merge. Thank you!

@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Hi @adriadam10 and @oneandonlydean,

Rebased cleanly onto latest origin/main (d371ed3) on commit �d051126d:

  • All merge conflicts in docs/dev/TechnicalDebt.md cleanly resolved.
  • Strict 0-comment rule in C++ source files verified ( ools/check_conventions.py --base origin/main passes 100%).
  • Dedicated pure getrlimit scope answering FreeBSD process-0 limits for RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_CORE, RLIMIT_SBSIZE, RLIMIT_VMEM/AS, RLIMIT_NPTS, RLIMIT_SWAP, RLIMIT_KQUEUES, RLIMIT_UMTXP.
  • Unit tests in GuestGetrlimit.cpp cover all supported resources, null pointer checks, and unknown resource rejection.

Branch is clean (mergeable: true) and ready for review and merge when convenient! Thank you!

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-wait-rlimits branch from ad05112 to 7146d9c Compare October 12, 2026 02:51
@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-wait-rlimits branch from 7146d9c to 2781077 Compare October 12, 2026 06:40
@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Hi @adriadam10, following up on your earlier review: as requested, wait was completely removed to avoid overlap with #3715, and this PR is now strictly scoped to the 9 FreeBSD process-0 getrlimit defaults (RLIMIT_CPU, FSIZE, CORE, SBSIZE, VMEM, NPTS, SWAP, KQUEUES, UMTXP). Rebased cleanly on latest main with all 14 CI checks passing (mergeable: true). Whenever you have a chance to re-review, thank you!

@oneandonlydean oneandonlydean self-assigned this Oct 12, 2026
@oneandonlydean
oneandonlydean dismissed adriadam10’s stale review October 12, 2026 11:44

The points from this review are in the current head.

@oneandonlydean
oneandonlydean merged commit ffa1984 into boykopovar:main Oct 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants