Repository navigation
feat(libkernel): report RLIMIT_NOFILE through getrlimit - #5187
Conversation
|
Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, |
|
A title that stops here: XPSemu (PPSA97358). On |
|
Built and ran this on Windows: head
One thing for Linux, which I can't run here: right after |
XPSemu (PPSA97358) queries RLIMIT_NOFILE at start-up in QEMU's os_setup_limits and stopped on the unsupported resource. It reports the descriptor count after which AnyPS5 fails with EMFILE: the C runtime's 8192 low-level descriptors on Windows and the host limit on Linux. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a915c07 to
1aaec97
Compare
|
Rebased onto |
|
Checked on the PR merged onto main: build + ctest green (166/166, |
What
XPSemu (PPSA97358, catalog release) loads on current
mainonce #4377 (pthread_atfork), #4105 (execve) and #5061 (getdtablesize) are in (mlockalland theposix_spawnfamily are merged). It then stops at once:Resource 8 is
RLIMIT_NOFILE. The two call sites (guest 0xF5011B and 0xD21A78) are QEMU'sos_setup_limits:getrlimit(RLIMIT_NOFILE)warns "unable to query NOFILE limit" on failure, returns if the soft limit equals the hard limit, and otherwise raises the soft limit withsetrlimitand warns "unable to set NOFILE limit" on failure.getrlimit(RLIMIT_NOFILE)now reports, as both limits, the descriptor count after which AnyPS5 itself fails withEMFILE:_setmaxstdio). Guest files and pipes are C runtime descriptors, and guest socket numbers take one too (_open_osfhandleof aNULplaceholder inUdp.cpp), so they all share that table.RLIMIT_NOFILE, whose soft limit libkernel already raises to the hard limit at load (OpenFileLimit.cpp).Since both limits are equal,
setrlimitwith the same values succeeds as before and QEMU never needs to raise them. This mirrors the existingRLIMIT_DATA, which reports the host's limit. The console's own limit is unknown; thegetrlimitdebt entry is updated. Once this is in, #5061'sgetdtablesizecould report the same value (FreeBSD returns the smaller of the soft limit andmaxfilesperproc); I have kept that separate.Tested
main3faa9cb40with feat(libkernel): implement pthread_atfork registration #4377, feat(libkernel): add execve as a throwing export #4105 and feat(libkernel): add getdtablesize #5061. Before, it stops as above within 1 s. After, it gets pastos_setup_limitsand faults reading its GOT at the fixed console base 0x400000 (read of 0x339c6e0=rax + 0x400000). That is the load-address assumption Ruffle, VLC and XPSemu read their GOT at a fixed 0x400000 base from app0/imports.txt and fault once all imports load #4013 tracks (feat(relinker): support fixed Windows guest image bases #4140).guest_getrlimit:setrlimitwith them returns 0;pipeuntil it fails givesEMFILE, with every descriptor below the limit and fewer than 64 lost to the test process;python tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)os_setup_limits🤖 Generated with Claude Code