feat(libkernel): report vm.overcommit through sysctlbyname #5184

Merged
p3n1cillin merged 1 commit from upstream-pr/5184 into main 2026-10-14 01:52:26 +00:00
p3n1cillin commented 2026-10-13 14:09:51 +00:00 (Migrated from github.com)

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


What

PS5MC (PPSA99420, Kodi 22, catalog release) stops right after its heap: 2048 MiB of direct memory line on Windows:

terminate called after throwing an instance of 'std::runtime_error'
  what():  sysctlbyname_nid_postfix: unsupported name vm.overcommit

All three of its sysctlbyname("vm.overcommit") call sites (guest 0x3A4C351, 0x3A4CFA9, 0x3A4E43E) are mimalloc's unix_detect_overcommit. Each reads the page size through sysconf(47), then vm.overcommit into a zeroed 4-byte int, and sets mimalloc's overcommit flag from (result | value) != 0; mimalloc's start-up messages "secure level: %d" and "mem tracking: %s" follow the first site.

sysctlbyname("vm.overcommit") now reports 0, the default FreeBSD gives its int vm.overcommit. It goes through the existing CopyOut: a null buffer gets the length 4, and a short buffer gets a partial copy and ENOMEM. A write, which FreeBSD takes as a new policy, throws. The console's value is unknown; this is recorded under Unknown function info in docs/dev/debt/libkernel.md.

Tested

  • PS5MC PPSA99420 on Windows 11 (MinGW GCC 15.2.0). It loads only with #4379, #4374, #4383 and #5183, all on main 3faa9cb40. Before this change it stops as above within 3 s. After, mimalloc starts and Python's start-up is next (#5185, #5186); with those too, Kodi creates its GUI and runs for the whole 90 s run.
  • guest_system_configuration covers the length query, the value, a 2-byte buffer (ENOMEM, the rest untouched, errno otherwise unchanged) and a throwing write. All 125 libkernel tests pass on Windows; Linux was not built locally.
  • python tools/check_conventions.py --base origin/main passes. #5078 and #5098 add other names in the same part of SystemConfiguration.cpp and the same debt list; whichever merges later needs a trivial rebase.

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
  • Generic behaviour, not specific to one title
  • Depends on: none to build; PS5MC reaches it with #4379, #4374, #4383 and #5183
  • Unblocks: PS5MC (PPSA99420)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4844514546 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5184). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T14:09:51Z. --- ### What PS5MC (PPSA99420, Kodi 22, catalog release) stops right after its `heap: 2048 MiB of direct memory` line on Windows: ``` terminate called after throwing an instance of 'std::runtime_error' what(): sysctlbyname_nid_postfix: unsupported name vm.overcommit ``` All three of its `sysctlbyname("vm.overcommit")` call sites (guest 0x3A4C351, 0x3A4CFA9, 0x3A4E43E) are mimalloc's [`unix_detect_overcommit`](https://github.com/microsoft/mimalloc/blob/31d034d94cdb8e22f7d7ed55967f581a2d6e831d/src/prim/unix/prim.c#L129-L153). Each reads the page size through `sysconf(47)`, then `vm.overcommit` into a zeroed 4-byte `int`, and sets mimalloc's overcommit flag from `(result | value) != 0`; mimalloc's start-up messages "secure level: %d" and "mem tracking: %s" follow the first site. `sysctlbyname("vm.overcommit")` now reports 0, the default FreeBSD gives its `int` [`vm.overcommit`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/sys/vm/swap_pager.c#L158-L161). It goes through the existing `CopyOut`: a null buffer gets the length 4, and a short buffer gets a partial copy and `ENOMEM`. A write, which FreeBSD takes as a new policy, throws. The console's value is unknown; this is recorded under Unknown function info in `docs/dev/debt/libkernel.md`. ### Tested - PS5MC PPSA99420 on Windows 11 (MinGW GCC 15.2.0). It loads only with #4379, #4374, #4383 and #5183, all on `main` `3faa9cb40`. Before this change it stops as above within 3 s. After, mimalloc starts and Python's start-up is next (#5185, #5186); with those too, Kodi creates its GUI and runs for the whole 90 s run. - `guest_system_configuration` covers the length query, the value, a 2-byte buffer (`ENOMEM`, the rest untouched, `errno` otherwise unchanged) and a throwing write. All 125 libkernel tests pass on Windows; Linux was not built locally. - `python tools/check_conventions.py --base origin/main` passes. #5078 and #5098 add other names in the same part of `SystemConfiguration.cpp` and the same debt list; whichever merges later needs a trivial rebase. ### 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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none to build; PS5MC reaches it with #4379, #4374, #4383 and #5183 - [x] Unblocks: PS5MC (PPSA99420) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
p3n1cillin commented 2026-10-13 14:34:45 +00:00 (Migrated from github.com)

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


Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, BUILD_TESTING=ON, full build of a local test head 838d4fd85. That head is main 3faa9cb40 with this PR, my other open libkernel PRs (#5013, #5061, #5078, #5098, #5183–#5187, #5191) and the open PRs the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4467, #4863, #4105). All 123 libkernel and 69 libc tests pass, including guest_system_configuration, guest_getrlimit, guest_kernel_fcntl, guest_freebsd_clocks, guest_kernel_sys and guest_filesystem. Not built alone on Linux; no title run on Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147990660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5184#issuecomment-6147990660). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T14:34:45Z. --- Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, `BUILD_TESTING=ON`, full build of a local test head `838d4fd85`. That head is `main` `3faa9cb40` with this PR, my other open libkernel PRs (#5013, #5061, #5078, #5098, #5183–#5187, #5191) and the open PRs the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4467, #4863, #4105). All 123 libkernel and 69 libc tests pass, including `guest_system_configuration`, `guest_getrlimit`, `guest_kernel_fcntl`, `guest_freebsd_clocks`, `guest_kernel_sys` and `guest_filesystem`. Not built alone on Linux; no title run on Linux.
coltken95 commented 2026-10-13 18:48:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T18:48:47Z.


Tested on Linux x86-64 (Release build), with this PR alone (341fbb228) merged into main 9d0a41d5a:

  • With the PR: guest_system_configuration passes.
  • With main's sources and the PR's test: guest_system_configuration aborts.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152749283 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5184#issuecomment-6152749283). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-13T18:48:47Z. --- Tested on Linux x86-64 (Release build), with this PR alone (341fbb228) merged into main 9d0a41d5a: - With the PR: `guest_system_configuration` passes. - With main's sources and the PR's test: `guest_system_configuration` aborts. AI-assisted: yes (Claude Code)
babyhuey commented 2026-10-13 22:34:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-13T22:34:27Z.


A title that stops here on main: PS5MC / kodi-ps5 (PPSA99420, catalog release). Since #4379 (chflags) merged, main bf8dc610 stops it at sysctlbyname_nid_postfix: unsupported name vm.overcommit, just after it maps its heap and opens /dev/crypto (Linux, Ubuntu 24.04, GCC 13, Release, headless). With this PR (341fbb22, clean merge) guest_system_configuration passes. Kodi then starts properly: it loads its settings and initializes its services, and exits on its own at a later step, XBPython: Python initialization failed in _PyImport_InitExternal: external importer setup failed (a bare RuntimeError), then CServiceManager::InitStageTwo: Unable to initialize the python binding modules, XBMC_Run returned -1.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156653494 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5184#issuecomment-6156653494). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-13T22:34:27Z. --- A title that stops here on `main`: PS5MC / kodi-ps5 (PPSA99420, catalog release). Since #4379 (`chflags`) merged, `main` bf8dc610 stops it at `sysctlbyname_nid_postfix: unsupported name vm.overcommit`, just after it maps its heap and opens `/dev/crypto` (Linux, Ubuntu 24.04, GCC 13, Release, headless). With this PR (341fbb22, clean merge) `guest_system_configuration` passes. Kodi then starts properly: it loads its settings and initializes its services, and exits on its own at a later step, `XBPython: Python initialization failed in _PyImport_InitExternal: external importer setup failed` (a bare `RuntimeError`), then `CServiceManager::InitStageTwo: Unable to initialize the python binding modules`, `XBMC_Run returned -1`.
oneandonlydean commented 2026-10-14 01:45:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T01:45:17Z.


Rebased onto main to resolve the conflict in docs/dev/debt/libkernel.md after #5098; no other change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159030230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5184#issuecomment-6159030230). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T01:45:17Z. --- Rebased onto main to resolve the conflict in `docs/dev/debt/libkernel.md` after #5098; no other change.
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!5184
No description provided.