Repository navigation
feat(libkernel): support deferred cancellation in POSIX accept - #12965
Felipebmaitan wants to merge 116 commits into
Conversation
Keep native signals arriving beyond the receive timeout and bound the retained-owner wait. The same fixture rejects a source variant that incorrectly restarts its deadline after EINTR. AI-assisted: Codex
Read O_NONBLOCK from the native socket for every retained transfer so descriptor aliases and passed sockets do not turn nonblocking I/O into a blocking wait. Keep guest timeout accounting and native query errors intact. AI-assisted: Codex
Exercise real native descriptor aliases switching both blocking directions and a saturated nonblocking send after the guest descriptor closes, independently of SCM_RIGHTS. AI-assisted: Codex
… close the descriptor
…calls on a released thread handle
|
@JJenkx Investigated your report at #12965 (comment); the Windows hang remains unaddressed as a runtime defect. Current integration head Fresh Linux-only validation: Ubuntu 24.04.5 x86-64 container through Apple Silicon translation, GCC 13.3, Release. Production runtime libraries and focused accept/context/jump/stream/socket executables build; 39/39 selected CTests pass, followed by 100/100 The source audit followed
AI-assisted: yes. No PR merged/replaced and no history rewritten. |
What
Current integration head
e654da0e29634148ad5aa93c82edeb79236c1222preserves published accepte01288c9204944ae5befa08a514fb7d93443ac03and composes writes86dfdc9f090cc58983b78d0808a8fde1756415e4, including #12149 and the reads underscore-context repair. Current accept-only comparison. The Windows sigjump hang reported by @JJenkx is still unresolved. This update adds a bounded diagnostic guard, not a claimed lost-wake repair. Earlier maintenance descriptions below are historical.POSIX
acceptand_acceptnow wake on enabled deferred cancellation. The listener remains admitted through the native operation. An accepted native socket stays privately owned through deferred signal delivery; cancellation, thread exit or longjmp at that boundary disposes it before guest cleanup/TSD. Completed acceptance wins a pending cancellation request. libSceNet gains no cancellation point.This accept slice ships the ownership mechanism with its first consumer and tests. Connect is a separate follow-up. Incremental scope: 7 files, 249 insertions, 7 deletions.
Stack targeting main: #10817 / #10755, then #12682, then #12688, then #12700, then this PR. Exact prerequisite commits/authorship are preserved. The writes prerequisite resolves the shared socket/cancellation integration order agreed with its author; it does not expand the accept topic.
Composed base:
75b5ef3210dc6ad1e843b0419a4b02d30b92633e(source-free merge of feat(libkernel): cancel blocked POSIX writes with partial progress #12700daa3a810cbb43e399e3912df6bf3edb4221ef98cand main08a10d225306ad102b57408e2ef7566bcfb829b2).Accept-only comparison.
Composed stack against main.
Overlap checks were run. The #12700 overlap is resolved by the declared writes -> accept order and exact prerequisite merge. Nearby #11896 (receive flags), #10645 (socket events) and #10552 (macOS) do not implement this slice. The final scan also reports #7485 (accept address/length error precedence) and #12467 (UDP disconnect naming): those remain separate behavior changes; this slice preserves existing argument errors and does not claim to resolve their merge ordering. The refresh scan covered 1,454 open PR heads. Other reported overlaps are inherited in the composed prerequisites (#7090, #8463, #9019, #9938, #11625, #11831, #12005, #12130, #12135, #12170 and #12642); some stale branches cannot be compared automatically. This does not claim the whole stack is conflict-free with every open PR. No additional author agreement is implied.
Tested
Fresh Linux-only validation: Ubuntu 24.04.5 x86-64 container through Apple Silicon translation, GCC 13.3, Release. Production runtime libraries and focused accept/context/jump/stream/socket executables build; 39/39 selected CTests pass, followed by 100/100
guest_io_context_sigjumprepetitions (22.90 s total). Reads passed its 16-test selection plus the missing-restore negative control; transport passed 26/26 after an explicit stale-object rebuild; writes passed 364 selected cases. Conventions pass with the inherited SSL debt-length warning. No fresh Windows runtime, native macOS, title, console, GPU or performance run. A Linux repeat is not evidence that the reported Windows race is fixed. Upstream Windows workflow dispatch was denied HTTP 403 (admin rights required); no linked Windows environment API is callable in this session. Exact-head CI and maintainer bench remain outstanding. All evidence is pinned to upstream mainde824c2919ca65086c6324a1e0388866a7327eea; upstream advanced to18f594978831b1cac65bcc02cc0047781844c39dafter the final push and that newer composition has not been validated. Earlier results below apply only to their stated historical heads.Final composed head
e01288c9204944ae5befa08a514fb7d93443ac03:55161f97476a8bd413c279829cabb6390307e4d5, transport fix(libkernel): preserve blocking sockets over nonblocking native transport #126885dce7fea277f92c9e74db908ba1a0a5e0ebbe5c6, writes feat(libkernel): cancel blocked POSIX writes with partial progress #12700daa3a810cbb43e399e3912df6bf3edb4221ef98c, their prerequisites and current main08a10d225306ad102b57408e2ef7566bcfb829b2via clean merges. The composed-base commit exists only to provide an exact incremental comparison.net_dontwait_blocking_*cases were Not Run because their separate executable was omitted from the target list; after buildingnet_blocking_send_tests, all three passed on both platforms. No executed case failed.^guest_accept_|^guest_io_(write|read|recv|signal|descriptor|close|context)|^guest_socket_(options|connect_listening|stream_options|event|dontwait)|^guest_stream_close|^net_dontwait. Includes all 13 accept cases, read/write/borrowed-descriptor/context/close regressions, socket events and nonblocking receive cases. The inherited PEEK-readiness fixture and default SendBytes initialization fix remain intact; no TCP atomicity, data-loss or performance claim is made.guest_io_context_sigjump: another 100 repetitions with--output-on-failure, unchanged 15-second timeout, all passed.git diff --checkpasses.fd67319c67d4cc796660bad8823d49be873cc5b2versus composed base75b5ef3210dc6ad1e843b0419a4b02d30b92633e. Upstream reviewed the new writes default-buffer fix separately. No new accept implementation was introduced by this refresh.Unresolved reviewer hang: Windows 22621 report remains unexplained, not dismissed as load or classified as a confirmed lost wakeup. On Windows 26300, exact old accept
23691a5aa0f29643b2649f840732e3fd91b4ba57and composed writes baselined828f6cca320e8c1b335a86d401be40a45a2c977each passed 200 isolated CTest repetitions plus 1,000 process runs with a three-second stall detector and bounded GDB all-thread capture on stall. No stall occurred, so no failure stack was obtained. Another 1,000 temporary phase-instrumented accept runs passed. Instrumentation was removed; the restored exact accept head passed 23 context/accept cases ten times each. The cumulative harness and admission/exception code were compared against the prerequisite, not main, which lacks this harness. No problematic interleaving or general runtime fix was confirmed. The original reviewer's OS and preceding full-suite execution were not reproduced; logging changes scheduling. No diagnostic code remains.Address-waking tests were outside this focused selection. The known inherited failures remain unresolved; an upstream green writes run does not establish a fix.
Limits: no PS5 measurement, macOS runtime run, TCP/cancellation title run or performance claim. Descriptor-installation failure and disposal ordering before cleanup/TSD are statically reviewed, not directly fault-injected/asserted. General asynchronous cancellation and fresh native signals/nonlocal exits outside the controlled I/O boundary remain out of scope. Known gaps remain in
docs/dev/debt/libkernel.md.Checklist
Based on current
main; no other open PR implements the same functionsOne topic per PR; follow-ups go in a new PR
No comments in code except technical debt
Unimplemented paths throw (
NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt fileNo notes, investigation
.mdfiles or images added to the repository (attach them to this PR)New third-party code is a submodule built from source
Generic behaviour, not specific to one title
Depends on: feat(libkernel): cancel blocked POSIX writes with partial progress #12700 (transitively fix(libkernel): preserve blocking sockets over nonblocking native transport #12688, feat(libkernel): cancel blocked POSIX reads with owned operations #12682, fix(libkernel): return ESRCH from join, detach and cancel of a released thread handle #10817 and fix(libc): drop the kernel state of a descriptor that fclose or freopen closes #10755)
Fixes: none
Unblocks: none
GPUs tested: n/a
AI-assisted: yes