libkernel: getrusage(RUSAGE_CHILDREN) throws "unsupported who" and aborts the title; fix branch ready #3120

Closed
opened 2026-10-10 22:35:23 +00:00 by milescoviello · 1 comment
milescoviello commented 2026-10-10 22:35:23 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-10T22:35:23Z.


getrusage accepts only RUSAGE_SELF (0) and RUSAGE_THREAD (1) and throws std::invalid_argument("getrusage: unsupported who") for RUSAGE_CHILDREN (-1). FreeBSD's kern_getrusage (sys/kern/kern_resource.c) accepts it and returns p_cru, the summed usage of the children the process has waited for. A guest process here never has children (system runs no command and waitpid always returns ECHILD), so the console's answer is a zeroed struct rusage and 0.

Fix on my fork: milescoviello/AnyPS5:fix/getrusage-children (one commit, d5c92b22, on main 4d27834f; the 12 commits on main since then don't touch these files): RUSAGE_CHILDREN zero-fills the structure and returns 0, and other values still throw. guest_getrusage gains a check that aborts on main and passes with the fix. Linux only; Windows was not built or tested (the new path has no platform-specific code).

Setup: Gentoo, Linux 7.2.8, GCC 15.3.0, Release with CI's configure flags, main 4d27834f.

Tested: the new checks fail on main and pass with the fix. Full ctest with the fix on Linux (RTX 5090 Laptop GPU): no new failures; the only failures are the known agc_driver_dcc_keys_first_write (#2767) and two guest_video_out_* tests that time out with the displays powered off. tools/check_conventions.py passes. All five fixes I am filing today also pass their tests merged together on the current main.

Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5795894056 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3120). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-10T22:35:23Z. --- `getrusage` accepts only `RUSAGE_SELF` (0) and `RUSAGE_THREAD` (1) and throws `std::invalid_argument("getrusage: unsupported who")` for `RUSAGE_CHILDREN` (-1). FreeBSD's `kern_getrusage` (`sys/kern/kern_resource.c`) accepts it and returns `p_cru`, the summed usage of the children the process has waited for. A guest process here never has children (`system` runs no command and `waitpid` always returns ECHILD), so the console's answer is a zeroed `struct rusage` and 0. Fix on my fork: [`milescoviello/AnyPS5:fix/getrusage-children`](https://github.com/milescoviello/AnyPS5/tree/fix/getrusage-children) (one commit, `d5c92b22`, on `main` 4d27834f; the 12 commits on `main` since then don't touch these files): `RUSAGE_CHILDREN` zero-fills the structure and returns 0, and other values still throw. `guest_getrusage` gains a check that aborts on main and passes with the fix. Linux only; Windows was not built or tested (the new path has no platform-specific code). **Setup:** Gentoo, Linux 7.2.8, GCC 15.3.0, Release with CI's configure flags, `main` 4d27834f. **Tested:** the new checks fail on `main` and pass with the fix. Full `ctest` with the fix on Linux (RTX 5090 Laptop GPU): no new failures; the only failures are the known `agc_driver_dcc_keys_first_write` (#2767) and two `guest_video_out_*` tests that time out with the displays powered off. `tools/check_conventions.py` passes. All five fixes I am filing today also pass their tests merged together on the current `main`. Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit. AI-assisted: yes
hikazey commented 2026-10-11 00:53:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by hikazey on 2026-10-11T00:53:16Z.


Windows check, since the issue says Windows wasn't tested. This branch merged onto main f1ae427b, Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release with CI's configure flags.

build guest_getrusage
this branch 5/5 passed
Process.cpp reverted to main, test kept 5/5 failed
full suite with this branch 755/758 passed

Two of the full-suite failures also fail on plain main here (pr_overlap_encoding: the two *_error_preserves_unicode cases; guest_filesystem: line 276, guest errno 14), so they are unrelated. agc_driver_draw_cache_reuse also crashed once with 0xc0000374, the same intermittent heap-corruption exit as #3171.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103942745 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3120#issuecomment-6103942745). Originally posted by [hikazey](https://github.com/hikazey) on 2026-10-11T00:53:16Z. --- Windows check, since the issue says Windows wasn't tested. This branch merged onto `main` `f1ae427b`, Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release with CI's configure flags. | build | `guest_getrusage` | | --- | --- | | this branch | 5/5 passed | | `Process.cpp` reverted to `main`, test kept | 5/5 failed | | full suite with this branch | 755/758 passed | Two of the full-suite failures also fail on plain `main` here (`pr_overlap_encoding`: the two `*_error_preserves_unicode` cases; `guest_filesystem`: line 276, guest errno 14), so they are unrelated. `agc_driver_draw_cache_reuse` also crashed once with `0xc0000374`, the same intermittent heap-corruption exit as #3171. AI-assisted: yes (Claude Code).
Sign in to join this conversation.
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#3120
No description provided.