feat(libkernel): cancel blocked POSIX reads with owned operations #12682
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12682"
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 Felipebmaitan on 2026-10-29T01:56:01Z.
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
7d9ebe6a73merged onto maine772fb25cc. 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
a564d53d8fchanges 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
a564d53d8f(reads),95ce5937f2(transport) and6076fc5ca3(writes). Those published commits were adopted unchanged; only accept needed a new ordinary merge of the maintainer's writes head, producing82eaaf7766. 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
32169af1dc, transport70120f1b86, writesfbd44d3326. 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)Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:50:54Z.
Review: COMMENTED
Three things in the descriptor-access layer, which 12688 and 12700 carry as well.
GuestDescriptorAccess::Get(int)takes one process-wide static mutex and runsstd::erase_if(entries, expired)over the wholestd::map<int, std::weak_ptr<State>>before the lookup.DescriptorAccessInitialize_nid_no_patchcalls it for every read, recv, write and send. That is O(open descriptors) work under a single lock on each call, serialising every I/O thread in the process, not only the blocked ones. Sweep expired entries when a state is released, or keep a descriptor-indexed table with per-slot ownership, and keep the lookup off a global mutex.State::mutexandchangedcondition variable on the non-blocking path. A read that will return immediately still goes throughDescriptorAccessLock(lock,CanRead(),++readers). Please show what this costs a read/recv-heavy title againstmainwithtools/trace_digest.pysummaries from the same machine and scene, or say plainly that it is unmeasured.Mode::Closebranch ofDescriptorAccessLock, the closer loopsInterrupt()thenchanged.wait_for(lock, 1ms)untilCanChange(). A close behind a long blocked read becomes a 1 kHz wake loop, and the drain in the registry (if (pending) std::this_thread::yield()) is a pure spin on the registry lock.Process: the three PRs stack to +4.7k, +6.1k and +7.5k cumulative lines, so each Files tab hides which commits are new.
Unblocks: nonesits beside Human Fall Flat evidence. If PPSA02429 depends on this, please name it underUnblockswith the log line that reaches the blocking recv onmain, and state which of the 4.7k lines that title needs.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T17:47:04Z.
Review: APPROVED
Reviewed — approved
The merged tree builds and every test in its suite passes. Two production-only negative controls make the new read-cancel and close tests fail. I found nothing blocking. The non-blocking notes below cover the per-read cost of the signal layer and how
scePthreadCancelwaits on I/O.What I ran
Head
32169af1dc395b182370cdf973687d313d33bfc4,main1e658521a0a599872612bb91949311e2956b5283, merged tree9efdf6fa7f958f4c65380ddb06c776629a3058fd, all in a clean worktree. Release, GCC 14.2.0, Ninja, on Debian 13 (32 vCPU Xeon Gold 6136).Results
maingit diff --checkcheck_conventions.pylibs(build job)agc_driver_*denormal/division,guest_interfaces,guest_socket_options_multicast,unwrap_self_…,vector_constant_factor_tininess) also fail onmain.check_skips.pyguest_net_ctlskipped unexpectedly, which also happens onmainguest_io_context_sigjump)Focused run tail
Negative control
The new tests call new APIs (
GuestDescriptorAccess,JumpBuffer::GuestContext*), so restoring every production file frommainwould only break the build. I made two targeted production-only reverts instead:core/libs/prx/libkernel/File/src/Open.cpp:156, I replacedThreadCancel::Native([&] { return ::read(fd, buf, n); })with a plain::read. Thenguest_io_read_pipe_read_cancel,guest_io_read_pipe_read_complete,guest_io_read_pipe_alias_cancelandguest_io_read_pipe_alias_completefailed, each in about 2 s. Thependinganddisabledcases still passed, as they should.core/libs/prx/libkernel/File/src/Stdio.cpp:971, I removed theGuestDescriptorAccess … Mode::Closeguard inclose_nid_postfix. Thenguest_io_close_readers_0,guest_io_close_0_0_0andguest_io_descriptor_close_before_nativefailed. The socket variants close through other paths and passed.After both controls I restored the merged files from
9efdf6fa…and rebuilt. All 60guest_io_(close_|descriptor_|read_pipe)tests passed again, andgit status --porcelainwas empty. The author also reports a negative control on_longjmp's restore call; I did not repeat it.Findings
Blocking
None.
Non-blocking
A process-wide mutex and about 14 extra signal-mask syscalls on every POSIX read on Linux. This is new evidence for point 1 of CnRJay's review. The descriptor registry is now sharded, but the signal layer still serialises every POSIX read/recv in the process:
BeginIoSignalspushes ontomanager.entriesunder the singleSignalManager::mutex(core/libs/prx/libkernel/Pthread/src/IoSignals.cpp:260-263).EndIoSignalsrunsstd::eraseover that vector under the same lock (IoSignals.cpp:288-291).IoSignals.cpp:188-194).Counting from the source, each such read also pays for a large number of signal-mask syscalls:
SetupBlockruns in theIoRestartconstructor and destructor, inBeginIoSignals, and twice inEndIoSignals: 10pthread_sigmaskcalls.NativeIo::Stateadds an unblock, a block, asigpendingand a final setmask (core/libs/prx/libkernel/Pthread/src/NativeIo.cpp:57-60,82-88).IoRestart::State,SignalState,NativeIo::State).The description says this cost is unmeasured and makes no speed claim, so no rule is broken. Still, this path is hotter than the descriptor admission it was asked about. Suggested fix:
SignalStateonce per guest thread rather than per call.SetupBlockpairs when no deferred delivery is pending.trace_digestcomparison on a read-heavy scene before this lands.scePthreadCancelwaits on a target's I/O with no time limit, re-signalling it on every pass of a yield loop. In the mergedcore/libs/prx/libkernel/Pthread/src/Thread.cpp:1450-1460, the canceller loops whilethread->cancelIois set, callingcancelIo->Wake()(pthread_kill(SIGUSR2)/CancelSynchronousIo) andscePthreadYield()each time.mainalready loops like this for condition waits (Thread.cpp:1406-1414at1e658521), but those always wake. A read stuck in a host call that ignores the interrupt keeps the calling thread spinning at full CPU, andpthread_cancelnever returns. POSIXpthread_cancelonly queues the request.The debt entry says that cancellation and close "may delay … indefinitely", but not that the caller of
pthread_cancelblocks. Suggested fix: back off as the close path does (1–16 ms), or return after the request is queued and leave re-waking to a retry owner. At least state in the debt entry that the caller waits.Scope. The PR carries #12149's
_setjmp/_longjmp(declared underDepends on: #12149, which is still open). It also splitsguest_raise_exceptioninto per-case tests, adds descriptor admission todup/dup2/fcntl/stdio close, and adds deferred async-signal delivery. Each piece is tied to read cancellation, but together they make a +4.2k-line review unit. If maintainers prefer smaller units, the deferred-delivery layer (IoSignals.cpp,Signals.cpp/Exception.cpphooks, context identity) could stand on its own.Not verified
_longjmp'sGuestStackSwitch_nid_no_patchpath, theCancelSynchronousIopath, and the Windows-only tests (deferred_drain,close_progress,position_cancel,append_*).FileStream::Closenow callsstd::fclosewhile the same thread holdsflockfile(core/libs/prx/libc/include/FileStream.hpp:131-139,493-501). This is fine on glibc. I did not check Apple libc, which releases and reinitialises the FILE lock insidefclose.strace/perf, so the syscall count above comes from reading the source, not from a trace.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T09:38:22Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Head
32121ca48d0abf5e1c11e7c601636d10ec8cb77d, basemain. Read-only review, no merge preview, nothing built or executed. I read the wholediff.patch(lockfiles, minified files,dist/,build/and.svgexcluded by the console), the description, the commit list and the manifest. Repository reads at the head, all throughrepo_read.py:A search with escaped parentheses (
WaitUntil\(sleep) returned no match, so I searched the plain name instead.Results
Raw reader output
Findings
Blocking
None.
Non-blocking
core/libs/prx/libkernel/File/src/Stdio.cpp:339—IoPositionedTransferwaits on the positioned lock in 1 µs slices (DeadlineNanos(1000)). Only the interrupt callback notifieschanged; releasing the holder'sentry->mutexnever does. A second cancellable transfer on the same descriptor therefore spins until the holder finishes. Example: thread A holds the positioned lock across a 2-second native transfer; thread B'spreadon that descriptor runs the 1 µs loop for those 2 seconds and keeps one host core busy. A fix would notifychangedwhen the positioned lock is released, or wait on the lock itself. Not run here.core/libs/tests/GuestStreamClose.cpp:77— the positioned-write close race now compiles only on Windows. In the removed lines it ran on every platform with 16 rounds of 8 MiB. Linux and macOS lose that coverage, and the description does not mention it. If that is intentional, say so in the description, or keep the test on POSIX.core/libs/tests/GuestRaiseException.cpp:431—AddressRoundsdrops from 50 to 10, and the loop at line 488 uses it. The description does not explain the cut. If the smaller count is for runtime, say so; otherwise restore it.Sources
github.com/boykopovar/AnyPS5@32121ca48d/core/libs/prx/libkernel/File/src/Stdio.cpp (L322-L341)github.com/boykopovar/AnyPS5@32121ca48d/core/libs/prx/libc/include/FileStream.hpp (L131-L137)github.com/boykopovar/AnyPS5@32121ca48d/core/libs/tests/GuestStreamClose.cpp (L76-L78)github.com/boykopovar/AnyPS5@32121ca48d/core/libs/tests/GuestRaiseException.cpp (L431)Not verified
FileStream.hpp:134-135: on Windows,NativeLock::Closecalls_unlock_fileon the handle after_fclose_nolockhas run. I did not check whether the UCRT stream lock outlives the FILE, so the safety of that order is not verified.diff.patch, so callers ofIoSignals.cpp,NativeIo.cpp,Udp.cppandCancel.hppat the head were not checked.IoSignals.cppandNativeIo.cppbackends were not run; the debt docs say the same.files.jsonwas not opened, so I cannot confirm which files count as reviewed.docs/dev/debt/*.mdis unverified by nature and was not checked.To get this to a good state
Nothing is required. Optional: see Non-blocking above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:35:45Z.
Review: COMMENTED
Reviewed — comments
This review inspected the prepared change and selected implementation hunks, but the full changed-file set was not reviewed, so a formal merge decision is not justified.
What I ran
Head:
8da1e28eae9752480ffc76e3c88b3091cb67add2. No build or tests were run; repository access was read-only throughrepo_read.py.Results
Findings
Blocking
None identified in the inspected ranges.
Non-blocking
Not verified
Read:
review/description.md,review/commits.md, the opening portion ofreview/manifest.json, and selected ranges ofreview/diff.patchcovering descriptor access, jump-buffer handling, stdio locking, and parts of socket and descriptor-control changes. Repository code was not separately read through the pinned reader. The remaining diff, full changed-file contents,files.json, and repository context were not verified. No tests were run; testing claims in the description remain author-reported.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed implementation and run the relevant checks before making a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:51:18Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the source reviewed; the focused Windows and Linux test results below are author-reported, not runs performed in this review.
What I ran
Reviewed head
fb5fe804340f9df393b6bff36bb89c1ce9e67d38. Read the prepared description, commits, manifest, full diff, and all changed files listed in the manifest; the manifest marks every changed file included. Usedrepo_read.pysearch and targeted reads for descriptor admission, receive, cancellation, and context restoration paths. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently run the reported tests, CI, or maintainer bench. macOS, console behavior, live titles, GPU execution, and per-call performance were not verified. The description identifies the separate libcurl lease-retirement generation gap as technical debt.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T21:31:44Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this review; the author’s reported host test runs are not independently verified here.
What I ran
Reviewed head
44fde3b660ac816dace9ac0320f2002d23d5787dfrom the prepared bundle usingrepo_read.pyreader tools. No build or tests were run.Results
Findings
Blocking
None verified in the source ranges inspected.
Non-blocking
None.
Not verified
The changed lines in the following files were not fully read:
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/src/FileAndHeap.cpp,core/libs/prx/libc/src/RuntimeSupport.cpp,core/libs/prx/libkernel/CMakeLists.txt,core/libs/prx/libkernel/Pthread/include/Pthread.hpp,core/libs/prx/libkernel/Socket/include/SocketRuntime.hpp,core/libs/prx/libkernel/System/src/SignalSets.cpp,core/libs/prx/libkernel/System/src/Signals.cpp, all changed test files, anddocs/dev/debt/changes/posix-read-cancellation.md. Other changes in the changed files were also not exhaustively read. Windows and Debian CTest results, header and convention audits, and overlap comparisons are reported by the author and were not run independently. MacOS, console, live-title, and performance behavior remain unverified for this review.To get this to a good state
Nothing is required. Optional: complete the changed-line review and run the relevant checks on this head before requesting approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T23:51:52Z.
Review: COMMENTED
Reviewed — comments
The change’s core read and receive paths look coherent in the inspected code, but this review did not read every changed line, so a formal approval is not justified.
What I ran
Reviewed head
7983704eeb68a4bf6dfd56396e7d3ea414be5ab9against the prepared diff and repository source. I ran no build or tests; the reported CTest results are author supplied. The intended reader command could not be run through the available tools.Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
Not verified
I read the prepared description, commit list, manifest, diff excerpts, and targeted source for descriptor admission, I/O cancellation, large-file transfers, and socket receives. I did not read every added line in all 49 changed files; the complete changed-line set listed in the manifest remains unreviewed. Files excluded by rule were not enumerated because
files.jsonwas not available through the review reader. I did not run tests, CI, a build, or console and platform checks.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed lines before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T02:30:44Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
64e722f33e50a90827dfa1b198b760182630972dusing the prepared description, commits, manifest, diff, and targeted source ranges throughrepo_read.py. No commands or tests were run here; the test results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libc/src/DescriptorAccess.cpp:53-66:Get()performs its first lookup and later insertion in separate critical sections. If two callers encounter an expired weak entry, each can create a different state; a caller that loses the second lookup can return the winner, but its newly allocated state is destroyed while its custom deleter checks the shared map. The identity check avoids erasing the winner, but the duplicate allocation/deallocation path is harder to reason about under concurrency. Consider creating or replacing the entry atomically under the bucket lock, or document why this race is safe.Not verified
No tests were run in this review, and no behavior was exercised on a host or console. The targeted source review covered descriptor-state management, POSIX read wrappers, native I/O interruption, cancellation delivery, Windows socket receive/shutdown, stream locking, and jump/context restoration. All changed files in the manifest are marked included; the prepared diff was inspected selectively, not read in full.
files.jsonwas not available through the reader.To get this to a good state
Nothing is required. Optional: simplify or document the expired-entry concurrency path in
GuestDescriptorAccess::Get().Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T04:29:07Z.
Review: COMMENTED
Reviewed — comments
This review covers the prepared diff at head
e3c4edcd7a254b916d0b8be8521cc58079e3ccbc; the pinned repository sources and all changed-file texts could not be read through the available reader, so a formal approval is not supported.What I ran
No commands were run. I read the prepared description, commit list, manifest, diff, and files exclusion listing. The reader interface exposed document and repository read tools, but not the requested
repo_read.pycommand interface or a populatedreview/filesdirectory.Results
Findings
Blocking
None confirmed from the available evidence.
Non-blocking
Not verified
The reviewed manifest marks all 45 changed files as included, but none of their full texts were available in
review/files; no changed file was read from the pinned repository. No tests, builds, CI, or console behavior were independently verified. The description states macOS, console, live titles, GPU, and performance remain untested for this update.To get this to a good state
Nothing is required. The optional points above need source and CI review before a formal approval is justified.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T13:37:24Z.
Review: COMMENTED
Reviewed — comments
The review is incomplete because only selected implementation files and portions of the diff were inspected; no blocking defect is verified.
What I ran
7887e7a03da0e8aeed2557f4ba43a6aa777494b9using the prepared review bundle andrepo_read.pyreader tools.Results
Findings
Blocking
None verified in the inspected portions.
Non-blocking
None recorded; coverage was insufficient for a complete review.
Not verified
The changed-file list contains 53 files, all marked included in the manifest. I read the description, commits, the beginning of the manifest and diff, and selected ranges from
core/libs/prx/libc/src/DescriptorAccess.cpp,core/libs/prx/libkernel/Pthread/src/IoSignals.cpp,core/libs/prx/libkernel/Pthread/src/NativeIo.cpp,core/libs/prx/libkernel/Pthread/include/Cancel.hpp,core/libs/prx/libkernel/File/src/Stdio.cpp, andcore/libs/prx/libkernel/Socket/src/Udp.cpp. I did not read every changed file or the full diff. No tests were run, and the author-reported test results were not independently verified.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed files and run the focused checks on this head before making a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T05:34:17Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this review; I did not verify enough of the changed files to recommend approval.
What I ran
I inspected prepared diff
929529056fe8339d6f908975ca896a455386506dusingrepo_read.py. No build or tests were run.Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
None.
Not verified
Read:
review/description.md,review/manifest.json,review/diff.patch(selected ranges),core/libs/prx/libc/src/DescriptorAccess.cpp,core/libs/prx/libkernel/Socket/src/Udp.cpp(selected ranges),core/libs/prx/libkernel/File/src/Stdio.cpp(selected range),core/libs/prx/libkernel/Pthread/src/NativeIo.cpp,core/libs/prx/libkernel/System/src/UserContext.cpp, and selected ranges ofcore/libs/prx/libkernel/File/src/DescriptorControl.cpp,core/libs/prx/libkernel/File/src/Open.cpp,core/libs/prx/libc/src/JumpBuffer.cpp,core/libs/prx/libc/include/HostThreadLocal.hpp,core/libs/prx/libc/include/JumpBuffer.hpp, andcore/libs/tests/GuestIoDescriptorAccess.cpp.review/commits.mdwas not read. The manifest has 46 changed files, all marked included; only a subset were inspected. Remaining changed files and test coverage were not verified.To get this to a good state
Complete review of every changed file before making a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:56:27Z.
Review: COMMENTED
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.