fix(libkernel): close() and setsockopt() reach libSceNet sockets #4111
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4111"
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 jdmagic on 2026-10-11T23:29:56Z.
What
On the console a libSceNet socket is a kernel descriptor, so titles close it with
close()and set its options withsetsockopt(). libSceNet keeps its sockets in its own table, numbered from 32, and libkernel only looked at its own guest sockets:close()passed the number to the CRT, which reported an invalid parameter and left the socket open.setsockopt()returnedEBADF.libSceNet now registers a closer and an option setter with libkernel, as it already registers its poller for
select.sceNetSetsockopt, which the option setter calls, also acceptsSO_REUSEADDR,SO_BROADCAST,SO_SNDBUFandSO_RCVBUF, as libkernel's own sockets do. Because the two tables number independently, a CRT descriptor and a libSceNet socket can share a number, andclose()then closes the socket; this is recorded in TechnicalDebt.Sackboy: A Big Adventure (PPSA01289) sets
SO_BROADCASTon its UDP P2P socket withsetsockopt()inUIpNetDriver::InitBase. TheEBADFmade every listen fail, and the engine travelled back to its default map with?closed, reloading it about every two seconds behind the loading screen. Each time it tore the session down it also closed the socket withclose(), leaking one socket per attempt.guest_sce_net: a socket created withsceNetSockettakesSO_BROADCASTthroughsetsockopt()andsceNetSetsockopt, andSO_REUSEADDRthroughsceNetSetsockopt;close()closes it, andsceNetSocketCloseon it afterwards fails withEBADF.Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), on main
bca7a29d.guest_sce_net,guest_socket_events,guest_socket_pair,guest_socket_read_write,guest_kernel_errors,guest_filesystem,guest_file_vector: 7/7 passed. The fullctestwas not run on this branch.guest_sce_netchecks fail on main without the source changes.This PR and the two other libSceNet PRs from this branch set are independent and merge cleanly with each other.
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-11T23:35:34Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL430