Skip to content

libkernel: pthread_atfork, mlockall and getdtablesize are absent (XPSemu, VLC); branch ready #3628

Closed

Description

@screamm

libkernel lacks pthread_atfork (U9t5kJAWPnA), mlockall (x7g7Ebeo8-U) and getdtablesize (sZuwaDPATKs). From the relink registry order they are predicted stops of XPSemu (PPSA97358, indices 255, 201, 395) and VLC (PPSA85300, getdtablesize at 354 after #3556); not yet observed in a run. XPSemu calls pthread_atfork from a constructor (util/rcu.c:488-495), so that one must return.

Branch ready: screamm:feat/libkernel-xpsemu-process (three commits on main a11c8f7f: f37bccf6 feat(libkernel): implement pthread_atfork, 87f4aa33 feat(libkernel): add mlockall, 774670de feat(libkernel): add getdtablesize). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are.

  • pthread_atfork (new Pthread/Posix/Atfork.cpp): appends the three handlers to a locked list and returns 0 (ENOMEM on allocation failure), as FreeBSD 11.4 libthr thr_fork.c (8c639945); null handlers accepted; the handlers never run because fork throws here, which is recorded, and the list is exposed through PthreadAtforkHandlers_nid_no_patch() for a future fork. New guest_pthread_atfork checks order, null handlers, concurrent registration from four threads, and that nothing runs.
  • mlockall(flags): EINVAL for 0 or bits outside MCL_CURRENT|MCL_FUTURE (FreeBSD vm_mmap.c); valid flags throw naming the flag, because no mapping path can lock future mappings and mlock pins host pages range by range without a record to build on; XPSemu only calls it with -overcommit mem-lock=on. guest_mlock gains the cases.
  • getdtablesize: FreeBSD's syscall returns min(RLIMIT_NOFILE, kern.maxfilesperproc) (kern_descrip.c), and no public source (shadPS4, KytyPS5, OpenOrbis, fpPS4 placeholder, SharpProspero) gives the console's descriptor limit, so it throws like getrlimit(RLIMIT_NOFILE) still does; the export alone lets VLC and XPSemu load, and both call it only from their own closefrom, which XPSemu does not use. guest_getrlimit checks the throw.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: the three tests 3/3; ctest -j8 -E "^agc_driver_|^video_out_flip" 534/537, the failures being the known windows_exceptions (#3411), guest_kernel_sys (#3510) and guest_filesystem (#3518); with main's Process.cpp the extended getrlimit test fails; tools/check_conventions.py --base main and git diff --check pass. Not run on Linux.

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

Activity

  1. MarcZX10 commented on Oct 11, 2026

    @MarcZX10
    Contributor

    I carried the three commits from David’s ready branch into PR #3650, preserving his authorship. The PR adds pthread_atfork, mlockall, and getdtablesize as separate commits, with their known limits recorded in TechnicalDebt. On Linux/GCC 12.2 Release, all three targeted tests passed; conventions and git diff --check pass on current main. The PR text distinguishes the issue author’s Windows test report from my local run. The predicted title stops remain unobserved in a title run.

  2. MarcZX10 commented on Oct 12, 2026

    @MarcZX10
    Contributor

    I carried the mlockall and getdtablesize parts of the offered branch into PR #4386, preserving David’s authorship. Linux Release GCC 12.2 built guest_mlock_tests and guest_getrlimit_tests; both focused tests passed, along with conventions/diff checks. The PR documents that valid mlock operations and the console descriptor limit remain unsupported.

  3. oneandonlydean commented on Oct 14, 2026

    @oneandonlydean
    Collaborator

    Closing: pthread_atfork (#4377) and mlockall (#4386) are on main. getdtablesize isn't; it can go in when a title stops on it, so comment here with the title ID and the log line if VLC or XPSemu does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions