fix(libSceNet): close a libkernel socket through sceNetSocketClose #6140
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6140"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T23:10:22Z.
What
MXGP 26: The Official Game (PPSA30839) opens TCP sockets with libkernel's
socket(), then closes them withsceNetSocketClose.sceNetSocketCloseonly looked in libSceNet's own socket table, so it failed every one of those closes withSCE_NET_ERROR_EBADF(0x80410109), and the host socket stayed open. On the console, libSceNet's calls and libkernel's socket calls work on the same kernel sockets.Now, when
sceNetSocketClosegets a descriptor that libSceNet doesn't own but libkernel has open as a socket (GuestSocketIsOpen_nid_no_patch), it closes it through libkernel'sclose(). Any other descriptor still fails withEBADF, as before.The fallback runs after
g_mutexis released. libkernel'sclose()first asks libSceNet's registered socket closer, and that closer takesg_mutex.guest_sce_netgains a check:socket()and closes it withsceNetSocketClose;sceNetSocketClosefails withEBADF.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on
maineea428ca8:guest_sce_netaborts withmain'sExport.cppand passes with the change.guest_*tests pass.tools/check_conventions.py --base upstream/mainpasses.--to-intel, 90 s, every libSceNet socket call traced under gdb:main,sceNetSocketClosereturns0x80410109for descriptors 7, 9 and 11. 7 and 9 came from libkernel'ssocket(2, 1, 0).sceNetSetsockopt(11, IPPROTO_TCP, TCP_NODELAY)still fails withEBADF. Setting options on a libkernel socket through libSceNet is a separate change, and #5565 coversTCP_NODELAYon libkernel sockets.Not checked on a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T23:16:35Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceNet/Export.cppcore/libs/tests/GuestSceNet.cppcore/libs/tests/GuestSceNet.cppcore/libs/tests/GuestSceNet.cppcore/libs/prx/libSceNet/Export.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:53:53Z.
Checked build and ctest (guest_sce_net passes; it fails when Export.cpp is reverted), the lock ordering (fallback runs after
g_mutexis released) and the EBADF path for descriptors neither library owns; merging.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T20:02:22Z.
@adriadam10, I rebased this onto
maine3838332eearlier today, as part of rebasing my older PRs. The head moved from 1c6505156 to8b81fa09band the patch is unchanged (git range-diffshows=). In case your merge didn't go through: after the rebase,guest_sce_netpasses 3 of 3 and^guest_passes 409 of 409.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T15:23:26Z.
Merged while @adriadam10 is away: the review passed and full CI is green on this head.