Skip to content

test(libkernel): wait for the loopback datagram in the reused-descriptor select check - #22313

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Jazeupoi:test/select-poll-loopback-wait
Nov 17, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Jazeupoi:test/select-poll-loopback-wait

Conversation

@Jazeupoi

Copy link
Copy Markdown
Contributor

What

guest_select fails on macOS since #21905 added ReusedDescriptorNumberIsSelectedFresh. The check sends a datagram on a UDP socket connected to itself, then calls select with a zero timeout and requires the socket to be readable at once. On macOS a loopback datagram is queued asynchronously. A host program that sends to itself on 127.0.0.1 and then calls select with a zero timeout sees it readable in 1 of 200 rounds, so the check fails on most runs.

The check now waits up to one second for the datagram. It still checks what #21905 pins: the reused descriptor number must be looked up fresh. A stale entry for the closed socket would not become readable or would fail. On FreeBSD and Linux the datagram is already queued, so select returns at once as before.

The poll counterpart, ReusedDescriptorNumberIsPolledFresh, is left as it is. With #20161 merged, guest_poll passes 10/10 on this Mac with the zero timeout.

Tested

Apple M4, macOS 27.0.1, Apple clang 21.0.0, x86-64 Release build under Rosetta 2. Base: main e798a424c7 with #17425 and #11049 (needed for the macOS build).

build guest_select failed
base 19/20 and 9/10
base + this PR 0/10
base + #20161 2/10 (under heavy machine load)
base + #20161 + this PR 0/10

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 57358252f1:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_select_tests built cleanly.
  • CTest (guest_select):
    1/1 Test #5495: guest_select .....................   Passed    4.74 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified core/libs/tests/GuestSelect.cpp:187-188 timeout parameter change from {0, 0} to {1, 0} (1 second) for select_nid_postfix.
    • Verified that guest select timeout semantics correctly accommodate asynchronous loopback packet queuing on Darwin / BSD platforms without weakening the test assertion.
    • Verified GuestDescriptorSet initialization, bounds checking (reused + 1), and return code assertions (1 readable descriptor).
    • Verified that descriptor lifecycle (send, select, recv, close) remains fully balanced and cleans up descriptors 'reused' and 'held' cleanly.
    • Verified compliance with AGENTS.md conventions: no comments added, conventional commit format adhered to, no extraneous files or undocumented debt.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit 1af270f into boykopovar:main Nov 17, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants