Repository navigation
feat(libkernel): cancel blocked POSIX reads with owned operations - #12682
Open
Felipebmaitan wants to merge 90 commits into
Open
Felipebmaitan wants to merge 90 commits into
Felipebmaitan wants to merge 90 commits into
Conversation
This was referenced Dec 2, 2026
Open
Open
This was referenced Dec 3, 2026
12 tasks done
12 tasks done
ligmaSec
reviewed
Dec 3, 2026
ligmaSec
left a comment
There was a problem hiding this comment.
The trial merge conflicts in the descriptor, stdio and socket runtime. The operation ownership boundary deserves a regression with two blocked readers on the same underlying descriptor, so interrupting one reader demonstrates that the other reader can still receive data. For SOCK_SEQPACKET, please retain coverage that drains an already queued record before the peer-shutdown read reports EOF. Please put the new debt entry in a fragment.
AI-assisted: yes.
12 tasks done
12 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Head
929529056fe8339d6f908975ca896a455386506dintegratesmainf318c6c71fce10b591bfde3f72ce87650d74edb4. The merge keeps timer signal delivery from #19463 alongside deferred I/O cancellation. For WindowsSOCK_SEQPACKETpairs from #23341, the owned wait checks for EOF after peer close orSHUT_WRonce queued records are drained. It cancels and drains only its own pending Winsock operation. Completed records, including empty ones, retain their bytes and source-address results.The previous head
7887e7a03da0e8aeed2557f4ba43a6aa777494b9mergedmainb383285415f41862d469d025accfd64fecb0b13aand resolved the Windows socket-buffer conflict from #24382. The merge preserves the checked send buffer and receive writable-prefix contracts. The receive, prefix probe and datagram discard use the same owned Windows receive path, so a pending probe can wake on shutdown or be cancelled. Eight new tests exerciserecvandrecvfromfor streams and datagrams with a partially writable buffer.The previous head
e3c4edcd7a254b916d0b8be8521cc58079e3ccbcfixed the patched Windows runtime failure on64e722f33e. PatchedlibSceNetimported five C++ThreadCancelnames that the NID patcher renamed inlibkernel, so Windows could not resolve them. Native cancellation registration now stays inlibkernelaround the forwarded receive callback.libSceNetqueries interruption and controls restart through three C entry points preserved by the patcher.The previous head
64e722f33e50a90827dfa1b198b760182630972dmergedmain67b5dd48231724012b334d17ca68e5d3ae38abb2, including the archive-backed file changes from #11625. POSIXpreadkeeps main’s archive error translation inside the cancellation point and descriptor ownership guard. Archive reads that fault return-1and set guesterrno, and successful reads retain their byte count.The previous head
7983704eeb68a4bf6dfd56396e7d3ea414be5ab9mergedmainfd4aeed48318c7d0cebca53d1db9a316c872cc4cinto the existing branch. The merge preserves #24076’s large-file reads inOpen.cppandStdio.cpp. Each native read chunk can be interrupted. An interrupted read returns completed bytes if it has made progress. The single-call fallback retains the existing cancellation handling.GuestFileVectornow checks all four POSIX read entry points above the host’s single-call limit.The previous head
44fde3b660ac816dace9ac0320f2002d23d5787dmergedmainc8d5f91168d7d8c208478de6d555b6a34c1c9acfinto the existing branch and retainsfb5fe804340f9df393b6bff36bb89c1ce9e67d38as its first parent. Windows close and reopen release main'sungetcpushback buffer while holdingNativeLock, before the native stream closes or is replaced. The Windows descriptor close admission andNativeLock::Closepath are preserved.The libSceNet receive path now captures the native socket error before checking for interruption. On Windows, an empty forwarded
recvfrom(MSG_DONTWAIT)returnsEAGAIN. Interrupted forwarded receives still returnEINTR.The Windows pending POSIX receive owns its completion and shutdown events. Shutdown through any alias wakes the retained socket's registrations. Each receiver cancels only its own OVERLAPPED and drains it before releasing its socket and destination. A positive
MSG_WAITALLresult is preserved. The integration keeps main's noncancellableReadWatchpath, the forwarding and libcurl borrowed-socket paths, the post-wait EOF handling, and the checked address outputs.recvfromchecks an unreadable address length before descriptor admission, matching main's error order. POSIXrecvandrecvfromforwarded to libSceNet register native interruption while they hold descriptor admission, so close can drain them. Windows forwarded receives check for interruption during the existing readiness waits. The separate libcurl lease-retirement generation gap is recorded in technical debt.Windows positioned transfers share a condition across descriptor aliases. A cancellable positioned wait wakes on holder release or interruption. The stream-close fixture exercises the Windows offset-serialization path with observed admission and contention, and the portable FILE-lock order test runs on both hosts. The exception-address waking and waiting cases each run five processes of ten rounds, preserving fifty rounds per case.
Before #24382 merged, I compared the 62 branches in the overlap report with head
e3c4edcd7aon mainc52d532062fbf346b98f59f5b9fd32c81c263214. Three combine without a Git conflict, ten conflict when combined (#11831, #16826, #18197, #19463, #21463, #22048, #22391, #23341, #24382, #24406), and 49 conflict with main before combination. This was a source comparison. Combined builds and runtime behavior remain untested.#18112 forwards the receive exports through
libkernel_weband calls the existing libkernel exports. #18190 forwards them throughlibkernel_sysand also refactorsUdp.cpp. Its receive-provider composition must preserve cancellation. #24322 switches the build to copies ofUdp.cppsplit across new files. Those compiled copies would need to carry the cancellation changes forward even though Git merges the files cleanly. #24910 and #24917 compile the same UDP chunks and inherit this overlap from #24322. #24646 has a conflict with main inlibSceNet/Export.cpp. Its socket-option and sync changes are outside this PR’s receive paths. Main and this branch each define the existing libkernelrecvfromexport (lUk6wrGXyMw) once.#11896 declares #12682 first for the broader
MSG_WAITALLwork. #22048 overlaps therecvmsgcopy-fault path. #23341 is now integrated. In a source-only comparison onf318c6c71f, #24944 merged cleanly with this head. #25017 overlaps the macOS readiness wait, and #25791 overlaps the Windowsrecv,recvfrom, andrecvmsgpaths with descriptor passing. Both combinations conflict inUdp.cpp. Combined runtime tests were outside this run. #12688, #12700 and #12965 depend on the reads layer. #12682 has no open prerequisites.Tested
SHUT_WR, and completed nonempty and empty records.mainf318c6c71fce10b591bfde3f72ce87650d74edb4. A virtual merge, conventions check, and whitespace check passed against the pre-push tip1de65493a2b913ae202e2f751f7c6377bed1fccb. The debt check passed, and the public-header audit verified 413 libraries and 34,900 exports.Hosted CI and the maintainer title bench are pending for this head.
Historical PR evidence at earlier heads
At
7887e7a03da0e8aeed2557f4ba43a6aa777494b9, before the timer and sequenced-socket integrations.Tested
guest_udp, forwarded reads, descriptor close, cancellation, shutdown, patched LibreSSL BIO and CMAC, large-file I/O and archive reads. Each of the eight new Windows prefix cases also passed ten consecutive executions.mainb383285415f41862d469d025accfd64fecb0b13a. A virtual merge, conventions check and whitespace check passed against the pre-push tip4f5777f2f320111b156ed5db843a6d5f67968923. The debt check passed, and the public-header audit verified 413 libraries and 34,810 exports.7887e7a03dand verified no blocking findings in that scope. The review is incomplete and recorded asCOMMENTED. The reviewer ran no tests. ReviewThe hosted Windows job was cancelled at the configured 90-minute limit in the build-and-run step, while Ninja was compiling the test targets. The log contains no compiler or test failure before cancellation, and the separate CTest step was skipped. Windows job
At
e3c4edcd7a254b916d0b8be8521cc58079e3ccbc, before the Windows socket-buffer integration.Tested
64e722f33ereported eight failures in 5,848 CTest entries. I reproducedWinError 127loading patchedlibSceNetlocally and verified the missing imports against the patchedlibkernelexport table.libkernel,libSceNet,libSceLibreSsl, andlibSceLibreSsl3.patched_librariesloaded 6/6 staged modules. I used the generated Ninja recipes for these test binaries with only the needed patched modules staged.mainb612e96. It recorded 4,298 passed, 1,559 skipped, and zero failures across 5,857 CTest entries. All eight previously failing tests passed, including the fullpatched_librariesCI check. Windows jobmaina1b89f35e2using WinLibs GCC 15.2.0. Windows Server 2025 reported zero failures in both runs of 6,991 CTest entries. On Server 2022, both runs had two VideoOut failures also seen onmainbecausevulkan-1.dllwas unavailable. The first run additionally timed out inguest_libressl_tls_engine_transport, and the second aborted inguest_cpu_time_clocks. Neither appeared in the paired baseline failure lists. On local Windows 11 (10.0.26300), both fixtures passed ten consecutive executions each on that head. The Server 2022 failures remain unexplained. Contributor report · Server 2022 job · Server 2025 jobd8c98c0eb236f58be251f354d6354bc939f67559. A virtual merge with that tip completed cleanly. The debt check passed, and the public-header audit verified 413 libraries and 34,782 exports.64e722f33ewith one optional descriptor-state comment. ReviewThe maintainer bench remains pending for that head. The GitHub
linuxjob was skipped. All 22 executed GitHub checks passed. Local testing for this update covered Windows and Linux. Console, live titles, GPU and performance remain untested.At
64e722f33e50a90827dfa1b198b760182630972d, before fixing patched Windows loading.Tested
preadassertions. The selection also includes large file I/O, descriptor close, cancellation, stream close, and forwarded socket reads.005482d54a0caf61bb2919074716c987054e6c55. A virtual merge with that tip completed cleanly. The debt check passed, and the public-header audit verified 413 libraries and 34,782 exports.7983704eeband raised no defects or requests. ReviewCI and the maintainer bench remain pending for this head. macOS, console, live titles, GPU and performance remain untested for this update.
At
7983704eeb68a4bf6dfd56396e7d3ea414be5ab9, before the archive-backed file integration.Tested
c7084de6edbc1f86c8e8ea3361383459545f37bb; a virtual merge with that tip completed cleanly. The debt check passed, and the public-header audit verified 413 libraries and 34,780 exports.44fde3b660and raised no findings. ReviewCI and the maintainer bench remain pending for this head. macOS, console, live titles, GPU and performance remain untested for this update.
At
44fde3b660ac816dace9ac0320f2002d23d5787d, before the large-file read integration.Tested
ungetc, the five standard-stream cases, the stream-close race, forwarded receives, and cancellation and shutdown coverage.origin/main4c3e1569aad89728238c94cc6ef83bfad44d2926, which adds separate SaveData tests. A virtual merge with that tip completed cleanly.fb5fe804340f9df393b6bff36bb89c1ce9e67d38after reviewing the full change. ReviewCI and the maintainer bench remain pending for this head. Local execution covered focused host tests. macOS, console, live titles, GPU and performance remain untested for this update.
At
fb5fe804340f9df393b6bff36bb89c1ce9e67d38, before the Windows pushback integration.Tested
8da1e28epassed 110 repeated executions of positioned, forwarded-close, address, and partialMSG_WAITALLcases.guest_sce_net_kernel_forwardsabort on8da1e28e, then included the fixture in both final platform runs.origin/main, debt fragments, and whitespace checks passed.79d49f2864f62423b2d72dc0676af685b0d61bf3and found a forwarded-receive close hang. The fix above was rebuilt and tested on both hosts. With the pre-fix LinuxlibSceNetbinary loaded, both new tests failed at the close-wake assertion. Both pass with the final runtime.The runtime runs cover focused host tests. The maintainer bench and CI for this exact head remain open. macOS, a console, live titles, GPU execution, and per-call performance were untested for this update.
What
Published head
32121ca48d0abf5e1c11e7c601636d10ec8cb77dpreserves November published readsa564d53d8feacc77e94cc6301f35b41175fff6a0and merges fetched main4138defef7c468835190768e5143e411bce92d6awith authored history intact.Address Dean's shutdown integration request. A Windows pending overlapped receive now waits on its private completion event and a shutdown event registered against the retained socket object. Shutdown reaches every registration through any alias; the receiver cancels only its own OVERLAPPED and drains completion before releasing native/destination ownership. Actual cancellation remains separate, disabled cancellation stays pending, and completed positive MSG_WAITALL progress is retained. Main's post-wait ReceiveShut checks, empty recvfrom/recvmsg address handling, and receiver argument/noncancellable ReadWatch path remain. Main's measured ucontext layout is retained with the existing opaque I/O identity in reserved spare storage.
This PR remains the read-cancellation consumer. The remaining Windows native/SCE readiness-to-transfer gaps are explicitly retained in debt here and handled in the separate transport dependency. No other owner's branch was edited. Previously declared prerequisites #10552/#10817/#10755/#12149/#9019 have landed; Depends on remains none.
Tested
Fresh local execution of the published source/head above, Release, CPU build jobs capped at two:
ed37723bdb31651c1e76574ab55befafb447daac: no confirmed new must-fix defect. Subsequent changes only clarify debt and add the Unix timeout observation call; the Windows wake/ownership algorithm is unchanged. Reviewers ran no binaries; runtime evidence above is this owner's execution.These are relevant production builds and focused runtime selections, not execution of the entire project suite. WSL userfaultfd write protection is unavailable and the existing memory-comparison fallback is reported by the runtime. Existing user FreeType submodule state was preserved. No fresh macOS, title, console, GPU, allocation-failure or performance qualification; event/allocation/syscall/cancelling-caller costs remain unmeasured. Native/SCE receive gaps, macOS unconnected datagrams and zero-length datagram timestamp races retain debt. The unrelated address-waking intermittency and historical Windows 22621 sigjump hang remain unresolved. Maintainer scene/bench and new-head CI/review are separate gates; earlier approvals/results are not approvals of this head.
Historical evidence and status at earlier heads (superseded where stated above)
What
Head
a564d53d8feacc77e94cc6301f35b41175fff6a0, integrated maind23df92b3805fea21493a73cbed8835c9e8548d0through ordinary merge history, preserving every previously published head and maintainer commit.Implement POSIX read cancellation with descriptor lifetime admission, deferred asynchronous delivery and context retirement. Retain the underscore context repair without guest signal-mask saving, checked context copies, deterministic close controls and main's current fault-delivery behavior. Document that scePthreadCancel blocks its cancelling caller and can wake/yield indefinitely; SignalManager global registration locking, allocations and mask-syscall cost remain unmeasured. This update changes that debt rather than adding an optional signal redesign or making a speed claim.
#12149 merged November 4 at 05:34 UTC and #9019 merged November 4 at 17:34 UTC; both are satisfied in main. #10552/#10817/#10755 are also merged. All four Apple empty-iovec guards, general context restoration, synchronous writes and deterministic stream-close hooks/comparisons remain. No archive #11625 work or unrelated owner branch was changed.
Consolidated maintainer response and evidence.
Tested
Historical contributor AMD evidence: TechLevelZero, 2026-11-05 13:22 UTC, parent reads 7d9ebe6 merged onto main e772fb2. RX 6300/RADV NAVI24, Mesa 25.2.8-0ubuntu0.24.04.4/Vulkan 1.4.318; Ubuntu 26.04.1/kernel 7.0.0-42/container ubuntu:24.04, Release. The contributor reports 4,279 passed / 15 failed / 71 skipped: ten failures also on main and five unstable on main, zero reported new failures. Validation/no-cache was enabled; 1,408 tests ran on the GPU, with no reported new IDs and four baseline IDs retained. agc_graphics_profile_draw timed out in the parallel run and passed on the 360-second retry. Baseline failures/skips and slow-test warnings remain visible; this is not an all-green result.
The displayed 4,365-of-4,074 selection line differs from linked 07-select.log's 4,326/4,400, so no unique whole-suite coverage ratio is inferred. This is contributor-reported evidence, not our GPU run or an independent audit of all linked logs. Parent-to-current a564d53 changes only MainThreadMacOs.cpp, GuestMainStackMove.cpp, GuestNpCommonRuntime.cpp and kernel debt; the read/cancellation implementation, descriptor control and underscore context repair are unchanged. The old head/main test does not become blanket qualification of the current integration. Current Windows results are recorded separately. It does not measure per-call I/O cost or the cancelling caller's spin, qualify unpublished runtime candidates, resolve Windows 22621 or the old accept macOS timeout, or supply a title performance/paired trace_digest run. No new I/O fix or source push follows from this report.
Current-head Windows verification: native Windows job succeeds at
a564d53d8feacc77e94cc6301f35b41175fff6a0. The earlier manual dispatch HTTP 403 remains historical; dispatch is no longer a blocker for this head's Windows execution. This success is read from GitHub job status; no per-fixture totals are inferred here. The sibling transport log supplies direct execution evidence for its requested socket tests, and the accept log supplies direct evidence for its installation/disposal cases. Other checks remain incomplete with no observed current failures. Reads/transport/writes approvals remain pinned to earlier parent heads; no new review is inferred. The old accept macOS x86-64 timeout remains unexplained, and accept stays draft for the unresolved Windows 22621 hang.Main-integration follow-up: authoritative head
a564d53d8feacc77e94cc6301f35b41175fff6a0, maind23df92b3805fea21493a73cbed8835c9e8548d0. During the reads overlap audit the bot refreshed to 12 compared / 81 uncomparable branches at 2026-11-05 12:56:19 UTC. #15698 is confirmed merged; its removed row is satisfied by main. The other removed rows are not treated as merged or cleared merely because they disappeared. The remaining compared heads match the selected-source audits; no new implementation dependency. The existing-main recvfrom notice was checked: one implementation definition and one canonical declaration in main and reads, with no duplicate registration to remove.The pre-push fetch caught maintainer commits a564d53 (reads), 95ce593 (transport) and 6076fc5 (writes). Those published commits were adopted unchanged; only accept needed a new ordinary merge of the maintainer's writes head, producing 82eaaf7. Main's macOS process-start-block pages stay mapped, and the debt still states that POSIX read/receive waits wake and defer delivery until ownership guards are released. No maintainer source resolution was overwritten.
All four authoritative heads pass required conventions and whitespace checks (the existing SSL warning remains on the upper layers). The changed MainThreadMacOs.cpp passes host macOS x86-64 syntax checking. Linux I/O production sources and the selected I/O fixtures are unchanged from the earlier composed 93-test run; guest_socket_dontwait passes again against those unchanged Linux binaries (1.93 s; 2.07 s CTest total). This is not execution of the macOS stack-move fixture or a fresh full-suite run. The refreshed coordinated overlap scan covers 1,831 PRs and fails closed for 84 uncomparable branches at the top accept tree; the reads report's 81 count has different scope and remains uncleared. No repeated no-change overlap comment is posted. New integration-head checks/reviews remain pending; earlier runtime results and approvals below are historical at the heads they name. The earlier manual dispatch was denied HTTP 403; current Windows jobs are recorded above, so dispatch is no longer a blocker for these heads; the intermittent Windows 22621 hang and old accept macOS x86-64 timeout remain unresolved. Accept stays draft.
Composed accept tree
6db995790dbe9193ee44028e327ad907faaa5cbawith maine772fb25cc72ee5faf77847f06bbc69533016e82: Ubuntu 24.04.5/GCC 13.3 Release, x86-64 Docker through Apple Silicon translation. Rebuilt libc/libkernel/libSceLibcInternal/libkernel_sys and focused fixtures. 30/30 selected socket/UDP/context/accept tests pass (4.60 s): guest_socket_dontwait 1.78 s, guest_udp 1.59 s, all 15 accept cases including both installation failures and cancel/jump handoff disposal. 63/63 selected synchronous-write/stream-close tests pass (3.13 s). These are composed-stack focused results, not a full suite or independent runtime runs of every layer. Both requested test removals are present; implemented nonblocking/peek and delayed partial-buffer cases remain.Required
python3 tools/check_conventions.py --base origin/mainchecks pass for all four final heads, using an isolated Git context whose origin/main is the actual fetched upstream main above. Reads has no findings; upper layers retain only the existing SSL debt-length warning. Whitespace, preserved-parent and bottom-up ancestor checks pass. The coordinated stack overlap scan covers 1,811 open PRs and fails closed for 100 uncomparable branches; no whole-branch overlap clearance or owner-order agreement is claimed. Latest main and all four remote heads were fetched before the atomic fast-forward-only push. GitHub reports all four branches merge cleanly.Earlier Windows verification status, superseded by the current results above: After the earlier publication, ordered Build dispatch
12682 12688 12700 12965was rejected with HTTP 403, “Must have admin rights to Repository.” At that point a collaborator/admin dispatch was requested for guest_socket_dontwait plus native Windows guest_socket_transfer_progress; current runs above now supply execution. The available MinGW 13 cross-syntax attempt stops at newer main's_fflush_nolockdeclaration; no native Windows execution is inferred. The previous published heads' Windows jobs passed, but do not qualify these updates. New-head CI/review requires refresh.Prior XairRrR approvals are historical: reads 32169af, transport 70120f1, writes fbd44d3. Accept's prior review is COMMENTED and it remains draft. No new approval is inferred.
The old accept macOS x86-64 job126136729127 remains failed at attempt 1; refreshed status/log reads 668 passed and guest_none_relocations timed out at 20.12 s, 354.88 s total. Its cause and a fix are unestablished; there is no fresh full macOS runtime qualification. The intermittent Windows 22621 sigjump hang remains unresolved; these Linux passes do not resolve it. Retained SSL waits, per-call I/O overhead and the cancelling-caller indefinite spin retain their debt/limits. Unpublished signal-registry/cancellation-request and SyncWrites-exception candidates are excluded. No new title/console, GPU or paired same-scene trace_digest run; no performance claim. Maintainer title-scene bench remains external.
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)