roadmap BUILT

514. The HVF leg's std listener test hangs in some full runs and passes alone

Promoted from the proposal the-hvf-std-listener-hangs-in-some-full-runs, filed 2026-09-19, on calef's instruction of 2026-09-20 to give every proposal on main a number. The text below is the proposal's own, unedited, by the promotion rule. Found by milestone 227 (a GICv3 driver, because GICv2 boots and)'s lane (a GICv3 driver), on the first two full script/test --hvf runs this machine could make since milestone 222 (the one command a person runs before).

It needs an Apple Silicon Mac with HVF, and nothing else.

In brief

kernel::user::tests::a_std_program_serves_a_granted_listening_port hung in two of the three full script/test --hvf runs that reached it (the third was green end to end), and passes when run alone under HVF (cargo xtask test --hvf --test a_std_program_serves_a_granted_listening_port) and in every TCG run, GICv2 and GICv3 alike. It is the one flaky test left on the HVF leg, and script/ci-build names it when the leg fails so a contributor can tell it is not theirs. That sentence should go when this lands.

What the transcript shows, in order:

test kernel::user::tests::a_std_program_serves_a_granted_listening_port ...
  user thread 4294967418 killed: BRK instruction
    pc 0x000000000040e7dc   far 0x0000000000a50000   user sp 0x0000000000500b10   esr 0xf2000000
  the kernel is fine.

WATCHDOG: no progress for ~60 s. Every core idle, every thread blocked: a lost-wakeup hang.

and after the run, from the host's inbound prober:

inbound check (aarch64) FAILED: the guest served 2 of the 4 inbound connections ...
    +18822 ms: answered after 18613 ms, 9 bytes
    +18823 ms: answered after 1 ms, 9 bytes
    +109147 ms: stopped-while-waiting after 90324 ms, 0 bytes

0x40e7dc in std_exerciser is __rust_abort, so the std program panicked, and its message went nowhere a transcript reads.

The likeliest reading, which is not established

serve_one_inbound (std_exerciser/src/main.rs) panics with "round N: nobody connected" when accept returns an error, and std-nife's accept returns WouldBlock when net_stack's bounded wait expires. probe_inbound (xtask/src/main.rs) holds each connection it opens until it is answered or the run ends. Suppose the prober opened a connection in the gap between the hand-written listener's window and the std one, and that connection is never delivered to the std listener. The prober waits on it for the rest of the run (the 90-second stopped-while-waiting above), and the std listener's bounded wait expires with nobody connecting. HVF runs the suite about three times faster than TCG, which reshapes that gap. None of this was confirmed by instrumenting it.

Two defects may be here, and the second is independent of HVF

  1. The timing, as above: whatever it is, it is HVF-shaped.
  2. A kernel test hangs rather than fails when the program it waits on dies. The test waits for a report on a rendezvous; the std program is dead; the watchdog fires 60 seconds later and calls it a lost wakeup, which it is not. A test that saw its reporter killed and failed at once, saying so, would have turned this into a one-line red.

What would settle it

Capture the std program's panic message (its stderr reaches no transcript today), and log the prober's connection opens against the guest's listen and accept times on one clock. If the reading above holds, the fix is on the host side of the prober or in the listener's retry, not in the kernel.

What the evidence showed (2026-10-12 UTC)

Both instruments the block asked for were built first, and the evidence then picked the fix.

What was built

  1. net_stack resets a peer whose handshake landed in a listener being closed (close_tcp, in a new child components/src/tcp_close.rs, since ยง282 (when a file is split, the parent becomes an index) lets net_stack.rs only shrink). abort and one poll instead of close, which is what Linux does to a closed listener's unaccepted connections.
  2. A std test fails at once when its writer dies (defect 2): drain_sink_from in system_tests/src/user/std_tests.rs binds a notification to the test thread, ticks it every 100 ms, and on a tick asks whether the writer's thread still exists. A dead writer fails the test with everything it wrote, panic message last. start_net_std hands back the writer's thread, and the four std net tests (two per ISA) use it. Proven by making std_exerciser panic in round 1: the test failed with INJECTED: round 1 dies on purpose in the same second.
  3. The one clock (InboundProber::mark, xtask/src/inbound.rs), and the std test echoes the program's lines as std listen| ... so they can be stamped. std_exerciser's accept panic now says how long it waited.
  4. The hand-written listener re-arms too (ACCEPT_TRIES, five 15 s windows, in components/src/socket_test_client.rs). Not the cause, but measured beside it. The prober's first connection is opened at boot and slirp backs its SYN off to 16 and then 32 s gaps, and every run here answered it about 10 s into a single 15 s window.
  5. script/ci-build's sentence naming this test as a known flake is gone, and notes/hvf-leg.md, notes/multicore-defect-curve.md (D13) and notes/virtualization.md (stale since milestone 227 (a GICv3 driver, because GICv2 boots and silently loses every interrupt)) say what is true now.

Verified

Full script/test --hvf on patagonia (Apple M-series, QEMU 11.1.1), one at a time, each started only once the 1-minute load was under 4 and no other QEMU ran: thirteen runs. Ten were of the fix before close_tcp moved into its child module and three of the final tree. Twelve were green end to end (347 passed, 13 skipped, the scanout and inbound checks passing), with the std listener test passing each time, about 90 s a run. One stopped earlier, at login_user_schedule_tests::suspending_a_user_ends_their_schedule_and_refuses_them_until_resumed (alice was not authenticated), before any network test ran; that test's BUGS records it.

Read the green count with its caveat. Four more full runs on the way here (one on the base commit, three with the instruments but before the net_stack fix) were green too. So at this load the unforced hang was rarer than the two in three of 2026-09-19 or the three in six of 2026-09-24 (load 14 to 25). Twelve green runs therefore say little alone. The evidence that the fix closes the cause is the forced pair: red without it, green with it, same forcing.

BUGS

Follow-on

Index row

kernel::user::tests::a_std_program_serves_a_granted_listening_port hung in two of the three full script/test --hvf runs that reached it (the third was green end to end), and passes when run alone under HVF (`cargo xtask test --hvf...