AnyPS5/docs/dev/debt
screamm e99816e8f3 fix(libkernel): give guest sockets ordinary descriptor numbers below FD_SETSIZE
libkernel numbered guest sockets from GuestSockets::FirstDescriptor
(0x10000000), so a title that puts a socket in a 1024-bit fd_set writes
fd / 8 bytes past it. The Epic Online Services SDK does this on its
RtcNetworkThread and three titles stop there (#1794):

Palworld PPSA23126 (queeeef, main a11c8f7f7):
  FATAL: unhandled exception 0xc0000005 on thread 37164 'RtcNetworkThread'
    rip 0x00007ffcdb1ea2be eossdk-ps5-shipping.prx.guest.prx+0xdea2be
    rcx 0000000010000005 rsi 0000000000400000 r12 0000000010000005
The Mound PPSA26223 (xXPBSXx, main 0a8b1d32b):
  FATAL: unhandled exception 0xc0000005 on thread 'RtcNetworkThread',
  rip eossdk-ps5-shipping.prx.guest.prx+0xefc6f4, rcx = 0x10000005,
  rsi = 0x400000
Dying Light 2 PPSA02262 (tv7):
  FATAL: unhandled exception 0xc0000005 on thread 'RtcNetworkThread'
    rcx 0000000010000005 ... rsi 0000000000400000 ... r12 0000000010000005

On FreeBSD 11.4 (8c639945) FD_SETSIZE is 1024 (sys/sys/select.h:58-59)
and sockets take the lowest free entry of the one process descriptor
table that files use (kern_descrip.c:1643-1660 fdalloc,
uipc_syscalls.c kern_socket through falloc).

Every socket number is now a real host descriptor: a zero-access NUL
handle registered with _open_osfhandle on Windows (as directory
descriptors already are) and an F_DUPFD_CLOEXEC duplicate of the host
socket on Linux. The socket table maps that number to the socket, so
"is this a socket" is a table lookup instead of a range check at the 31
former FirstDescriptor comparisons. close releases both the socket entry
and the number, dup and dup2 duplicate the number through the host table
and keep the socket shared, dup2 of a file onto a socket number drops the
socket entry, and sceKernelClose now closes sockets too. sceNetSocket and
sceNetAccept take their ids from the same table instead of a counter from
32, so libkernel and libSceNet numbers never collide.

select polls guest sockets alongside libSceNet sockets, the random device,
stdio and (on Linux) host descriptors; poll throws only for an open
descriptor that is not a guest socket and reports POLLNVAL otherwise.
File calls that used to fail with EBADF on the socket range return
FreeBSD's answer for a socket: lseek ESPIPE (kern_lseek), ftruncate and
getdirentries EINVAL (invfo_truncate, getvnode), flock EOPNOTSUPP;
fstat on a socket throws. pread on a closed descriptor returns EBADF.

title failing on host descriptor numbers; these three titles are that
case, and this change keeps host numbering for files and only moves
sockets into it.

Tests: guest_socket_descriptors (new: socket below 1024, select on a
socket and a file together, close frees the number for a file, dup of a
socket, sceKernelClose), guest_select (socket and pipe together, Linux),
guest_poll, guest_dup, guest_socket_pair, guest_fstatfs,
guest_posix_filesystem and guest_sce_net updated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 20378375b31eb5db922db6e55f45e44a4dae6445)
2026-10-13 03:22:36 +00:00
..
libSceAcm.md docs(debt): list the PPSA02530 imports in debt/libSceAcm.md 2026-10-12 21:51:37 +02:00
libSceAgc.md feat(agc): return null from the workload builders for unregistered streams 2026-10-12 15:22:21 -04:00
libSceAgcDriver.md Merge pull request #4809 from MarcZX100/codex/unaligned-shader-abi-4782 2026-10-13 15:36:40 +13:00
libSceAjm.native.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceAmpr.md Merge pull request #4207 from xXPBSXx/fix/ampr-amm-usage-stats 2026-10-12 22:57:04 +02:00
libSceAppContent.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceAudio3d.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceAudioIn.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceAudioOut.md docs(debt): remove the duplicated fused PPSA23566 line 2026-10-12 22:04:02 +02:00
libSceAudioPropagation.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceAudiodec.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceAvPlayer.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceBluetoothHid.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceCdlgG2P.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceCdlgPlayerReview.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceCesCs.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceCommonDialog.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceContentDelete.md feat(libSceContentSearch): implement the search calls over an empty library 2026-10-13 00:34:12 +05:30
libSceContentExport.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceContentSearch.md feat(libSceContentSearch): implement the search calls over an empty library 2026-10-13 00:34:12 +05:30
libSceErrorDialog.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceFiber.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceFont.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceGameLiveStreaming.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceGameUpdate.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceHmd.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceHmd2.md fix(exports): export the calls PPSA29866 imports 2026-10-12 21:32:38 +02:00
libSceHttp.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceHttp2.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceIme.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceJobManager.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceJpegEnc.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceJson2.md feat(libSceSaveData): answer sceSaveDataDirNameSearch2 2026-10-12 22:59:26 +02:00
libSceKeyboard.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceLibcInternal.md Merge pull request #4569 from pipe1os/feat/libkernel-fdopendir 2026-10-12 23:00:17 +02:00
libSceLoginDialog.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceMbus.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceMsgDialog.native.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceNet.md fix(libkernel): accept NOTE_EXTEND on a directory watch on Windows 2026-10-12 22:37:31 +02:00
libSceNetCtlApDialog.md feat(libSceNetCtlApDialog): run the offline access-point dialog lifecycle 2026-10-12 20:03:59 +01:00
libSceNgs2.native.md fix(libSceNgs2): reject unverified listener transforms 2026-10-12 23:12:40 +02:00
libSceNpAuth.md feat(libSceNpAuth): return the signed-out error from sceNpAuthGetAuthorizedAppCode 2026-10-12 22:54:23 +02:00
libSceNpAuthAuthorizedAppDialog.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceNpCommerce.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceNpEntitlementAccess.md feat(libSceNpEntitlementAccess): implement sceNpEntitlementAccessGetGameTrialsFlag 2026-10-12 21:58:36 +02:00
libSceNpManager.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceNpPartner001.md docs(technical-debt): drop stale EAAccess unknown-info line and move the new one off the section end 2026-10-12 18:46:44 +00:00
libSceNpSessionSignaling.md docs(debt): cite ASTRO BOT's call to sceNpSessionSignalingGetConnectionStatus 2026-10-12 22:05:40 +01:00
libSceNpTrophy2.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceNpWebApi2.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceOpusCeltDec.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceOpusDec.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libScePad.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libScePlayGo.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libScePlayerInvitationDialog.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libScePngEnc.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libScePosixForWebKit.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libScePsml_debug.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceRazorCpu.md feat(libSceRazorCpu): implement sceRazorCpuSync 2026-10-12 21:58:39 +02:00
libSceRtc.md fix(rtc): reject date strings ending at the minutes 2026-10-12 19:44:03 +00:00
libSceRudp.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceSaveData.native.md feat(libSceSaveData): answer sceSaveDataDirNameSearch2 2026-10-12 22:59:26 +02:00
libSceSaveDataDialog.native.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceShare.md feat(libSceShare): implement sceShareCaptureVideoClipExtended 2026-10-12 18:46:45 +00:00
libSceSharePlay.md feat(libSceSharePlay): implement sceSharePlayProhibitController 2026-10-12 21:58:43 +02:00
libSceSigninDialog.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceSsl.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceSystemGesture.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceSystemService.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceTextToSpeech2.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceUlt.md feat(libSceUlt): accept option parameters in sceUltQueueCreate and sceUltQueueDataResourcePoolCreate 2026-10-12 22:48:53 +02:00
libSceUsbd.md feat(libSceUsbd): pass USB devices and transfers through to the host with libusb 2026-10-12 22:32:42 +02:00
libSceUserService.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceVdecsw.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceVideoOut.md docs(videoout): preserve split debt layout after merging main 2026-10-12 14:32:58 -05:00
libSceVideodec2.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceVoiceChat.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceVoiceQoS.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceVrSetupDialog.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libSceZlib.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
libc.md Merge pull request #4766 from p3n1cillin/claude/libc-heap-report-for-game 2026-10-12 23:21:56 +02:00
libkernel.md fix(libkernel): give guest sockets ordinary descriptor numbers below FD_SETSIZE 2026-10-13 03:22:36 +00:00
libkernel_sys.md feat(libkernel_sys): implement pathconf 2026-10-12 22:56:28 +02:00
libs.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00
relinker.md docs(debt): mention --windows-gui and its lost output on the console entry 2026-10-12 21:02:32 +02:00
shader.md fix(shader): read the ancillary render target index as 0 2026-10-13 13:23:56 +13:00
ulobjmgr.md docs(debt): move library entries to one file per library 2026-10-12 20:38:29 +02:00