Repository navigation
feat(libcurl): bridge curl-owned sockets to guest descriptors - #17603
Conversation
Progress report (667dbde → b6b02f8)📈 System libraries: 40.05% (+0.02%, +7 implemented functions) ✅ 7 implemented
Changed libraries (implemented exports)
|
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, Vulkan hidden for this CPU-only run. The
Two things seem to be missing on Windows:
I haven't tried either change, so I couldn't run AI-assisted: yes. |
|
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.
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.
|
|
I followed up on @JJenkx's Windows linker finding with an independent local build and runtime probe of exact head With that local link change, the registered The author's Linux socket test passes, but this Windows runtime path remains unverified on the unchanged PR because the test does not link there. I did not run a title, external network transfer, or the full suite. The verbose instrumentation also changed timing, so the uninstrumented diagnostic run is the primary runtime result. AI-assisted: yes (Codex). |
…e-write fixture Forward the static host backend nonblocking hook locally in the Windows Transfers test, where the DLL does not export it. Link the Windows Sockets test with ws2_32 for its direct Winsock calls. Read socket family and type through SO_PROTOCOL_INFOW because Windows getsockname rejects unbound sockets. Update the pipe-write fixture to provide NotImplementedAt, matching the macro introduced on main on November 1.
|
Thanks @JJenkx and @DonRyuzaki for the independent Windows builds and runtime probes. I pushed
Linux verification: configuration and the prescribed build succeeded; all 9 CI for this head:
I could not execute anything on Windows on this laptop, so the Windows verification above is from CI only. Could you please rerun AI-assisted: yes |
|
Windows check of head f6d0ddb, tested as the PR head (not merged onto main). Setup: Windows 11 (build 26340), WinLibs GCC 15.2 (x86_64-ucrt-posix-seh), Release, BUILD_TESTING=ON. guest_curl_Sockets_tests and guest_curl_Transfers_tests now build and link. |
|
Windows check of head Setup: Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (r7), Ninja, Release,
AI-assisted: yes. |
|
Thanks @ThorstenFR-Cyber and @gabichuuuuu for the additional Windows runs. The socketpair readiness failure is a separate remaining finding from the earlier linker and unbound-socket fixes: one run passes the exact head, while the other fails after merging it with main e37e9fa. I’ll investigate the extra guest descriptor → native socket → revents path and retain the readiness assertion. Could you share the full failing log and the heads of the other PRs included in that merged tree, if available? I’m not treating the green head-only/CI runs as resolving this report. |
|
@MarrasFederico I reviewed f6d0ddb. The socket lifetime, owner checks and lock order look right to me. Before this can merge, the Windows failure gabichuuuuu reported needs fixing: with the head merged onto current main, |
|
Thanks for the review. Pushed 7df5a03: main is merged, Add rejects descriptors outside [0, 1024), and fdset updates its highest descriptor only after successful insertion. The new boundary tests and the recorded Linux curl suite pass (10/10 tests, three runs each); removing the guard fails the negative control. The earlier green Windows run tested f6d0ddb, not this new head, so it does not resolve the reported socketpair failure. Could you share the failing tree SHA and log, or rerun this head? I have corrected the description to make that distinction explicit. The optional ACTIVESOCKET change remains unimplemented; its existing unsupported-path throw is preserved. |
|
@MarrasFederico I reviewed 7df5a03. The design holds up: the bridged descriptors go into libkernel's own socket table, so they dispatch through the normal path and do not overlap the libSceNet descriptors, the ownership checks show no double close or reuse race, and no lock is held across a blocking call or a guest callback. Two things stop it from passing.
|
…sockets # Conflicts: # core/libs/prx/libkernel/Socket/src/Udp.cpp
Drop the PipeWrite.cpp hunk now that main defines NotImplementedAt_nid_no_patch itself, and split the post-transfer assertion so a failure names the unmet condition.
|
Thanks for the review. Pushed 5274251, after merging current main (
Linux: |
|
Updated
|
|
Windows check of head Setup: Windows 11 (build 26340), WinLibs GCC 15.2 (
AI-assisted: yes. |
|
Thanks @ThorstenFR-Cyber for checking |
What
Expose curl connections as real guest descriptors instead of passing host socket numbers across the guest ABI. The bridge installs duplicate native-handle leases in the existing kernel socket table, checks owner identity before retiring a lease, and follows curl's close and resolver-removal notifications. It retains the close callback and DATA snapshot independently of the easy-handle adapter, including pooled connections that outlive the originating easy handle.
Implements multi socket/action/all/assign/fdset, extra socket descriptors in multi wait/poll, open/sockopt/close callback and DATA options, multi socket callback/DATA, and ACTIVESOCKET/LASTSOCKET. POSIX pipe/file extras are leased too. Socket addresses are translated to BSD guest layouts; guest mode tracking follows the pinned backend's nonblocking transition without changing the submodule or its original implementation.
Sources: curl
801bd5138ce31aa0d906fa4e2eabfc599d74e793socket creation and close, sockopt/connect ordering, fdset/wait, resolver removal, and socket getinfo. Raw source downloads matched the pinned checkout byte for byte.Remaining gaps are explicit in debt: console ABI/error verification, virtual extra descriptors, non-socket extras on Windows, and lease-failure mapping. Forms, MIME callback duplication and HTTP/2 push ownership still throw, with specific closing conditions. The 12 stub-only export rows match the source.
Tested
Ubuntu 26.04.1 LTS, kernel 7.0.0-43-generic, GCC 15.2.0, Release,
BUILD_TESTING=ON, CMake 4.4.4 with Ninja 1.13 from a virtualenv. Mergedmain(1965e614cb) via normal merge commit24b1f05812, then addedb6b02f8a4c(test(libcurl): hold loopback server response until wait loop starts, fullb6b02f8a4c4fed86e9ce851e015bca8d511d546d) to fix the Windows loopback race incore/libs/prx/libcurl/tests/CurlSockets.cpp; the published history was not rebased, squashed or force-pushed.guest_curl*test executables and thelibcurllibrary target.ctest -R '^guest_curl' --output-on-failure: 100% tests passed out of 11 (exit 0).descriptor < 0 || descriptor >= 1024guard fromAddmakesguest_curl_socketsfail atcore/libs/prx/libcurl/tests/CurlSockets.cpp:445; restoring the guard makes the test pass again.core/libs/prx/libcurl/CMakeLists.txtanddocs/dev/debt/libcurl.md):CMakeLists.txt: Preserved main'ssrc/FormFree.cppandMimeCallbacktest topic while cleanly adding the PR'ssrc/CurlSockets.cpp, WIN32FD_SETSIZE=1024, and theSocketstest topic with WIN32ws2_32linkage. Verified that all.cppfiles undercore/libs/prx/libcurl/src/matchCMakeLists.txtexactly without duplicate or missing entries.docs/dev/debt/libcurl.md: Preserved main's text (includingcurl_formfreeandMIME callbacksentries under Functional), keeping the PR's updatedSocket ownershipandPush ownershipentries (all <= 1000 characters). Unimplemented exports list was updated to remove the 4 exports implemented by this PR (curl_multi_assign,curl_multi_fdset,curl_multi_socket,curl_multi_socket_action), leaving 12 stub entries that matchExport.cpp1:1.Add):core/libs/prx/libcurl/src/CurlSockets.cppline 323:Addchecksdescriptor >= 0 && descriptor < 1024, returningfalse/ no insertion when out of bounds, and exposedAdd_nid_no_patchinCurlSockets.hpp. Inproject,highestis only updated whenAddreturns true.guest_curl_sockets(core/libs/prx/libcurl/tests/CurlSockets.cpp) inErrorsAndExtraDescriptors()to verify that negative descriptors (-1), boundary descriptors (1024), and large descriptors (99999) returnfalsewithout modifyingguest_fd_setbits, and valid descriptors (42) set the bit properly. Also updated test helperIsSetwith bound checks.3rdparty/curltagcurl-7_81_0, commit801bd5138ce31aa0d906fa4e2eabfc599d74e793). Inlib/getinfo.c:540andlib/connect.c:1468,CURLINFO_ACTIVESOCKETreturnsCurl_getconnectinfo(...), which returnsCURL_SOCKET_BADonly if curl's connection cache contains no active connection for the handle (!find.found). Upstream curl has no concept of AnyPS5 guest registrations or guest-closed descriptors.curl_multi_socket_action(lib/multi.c:3044) returnsCURLM_OKfor unmatched sockets, notCURL_SOCKET_BAD. Without proof in the pinned upstream source that curl returnsCURL_SOCKET_BADfor unregistered guest sockets, the existing throw (NotImplemented_nid_no_patch("libcurl: unregistered active socket")) was preserved per project rules.b6b02f8a4c):guest_curl_socketspassed 30/30 and^guest_curlpassed 11/11.^guest_curlpassed 11/11.python3 tools/check_conventions.py --base upstream/main: All conventions checks passed (0 errors, 0 warnings).python3 core/libs/tests/test_public_headers.py --audit-only: 413 libraries, 34494 exports: unique declarations and umbrella coverage verified.git diff --check upstream/main...HEAD: completely clean (exit code 0).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)