Repository navigation
fix: wait for a macOS local socket in poll before every read and end four hided flakes - #1860
Merged
Merged
Conversation
A recv blocked on a local socket on macOS sometimes sleeps through its peer's shutdown, and then through its own end's too, while poll wakes for both. A link_mux connection whose node ended kept its core-side streams for good that way. Every macOS read now waits in poll first, as a read with a timeout already did; Linux and Windows reads are unchanged. Refs with-hide/hide-private#351
macOS refuses SO_RCVTIMEO once the stream has ended at the server, which is the end the test waits for, so the read runs on a thread of its own under a hang guard instead. Refs with-hide/hide-private#351
…ixtures Five device_bootstrap tests that each copied and stripped the 140 MB debug hided at once ran past the fixture's 10 s command bound. The remote_delivery, core_move and device_bootstrap fixtures now take a shipped copy that the first test process strips and signs under a lock, and each test gets a byte copy of its own. Refs with-hide/hide-private#321
…ang guard The lane's 120 s guard ended the reconnect journey saying nothing of where it stood. The journey prints each step and the Hide AI request's progress, and at 100 s prints its step and the distribution's processes. Refs with-hide/hide-private#339
A Windows shutdown cancels this end's own reads and writes; its peer hears the end when the handle closes, so the os contract (windows) leg failed the new test at its first round.
The peer-shutdown rounds run in an owned, bounded exact-test subprocess, since a read that missed its end cannot be woken in its process; the link_mux drain shuts its socket and joins its reader before failing; the shipped store reclaims half-made copies of every version and removes its own on failure; the WSL journey keeps its record in memory and prints it only on failure, with a ps bounded by an owned process.
…ling The peer-shutdown rounds and the WSL journey's ps kept their owned child only as a temporary, so a capture that could not confirm its end dropped the handle; each now keeps it, ends and reaps it, and then reports the original failure.
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.
Closes with-hide/hide-private#351
Closes with-hide/hide-private#321
Closes with-hide/hide-private#347
Closes with-hide/hide-private#330
Related: with-hide/hide-private#339 (diagnostics only; the issue stays open)
Summary
Five flaky hided tests, one cause each:
link_muxconnection end): on macOS arecvblocked on a local socket sometimes misses its peer's shutdown, and after that misses its own end's shutdown too. Then a core-side mux never saw its node end and kept its streams. Every macOSLocalStreamread now waits inpollfirst, which hears both. The test's ownSO_RCVTIMEO(EINVAL on macOS after the end) is replaced by a reading thread with a hang guard.device_bootstrap): five tests each copied and stripped the 140 MB debughidedat once, past the fixture's 10 s command bound. A shared helper now strips and signs each build version once under a lock, andremote_deliveryandcore_moveuse it too.core_movetests failed together. It has passed first try on main since. The cause of that run is not proven; the issue is closed on the later main passes (evidence in the issue comment).psbounded to 10 s, and ends the test. A passing run prints nothing.Review
pollbefore every local-socket read, against the kernel's lost wakeup, instead of changing each caller that waits for a peer's end.hide-platform/src/ipc.rs- high-frequency path: everyLocalStreamread on macOS (Herdr socket, mux, pane service).hided/tests/it/support/shipped.rs- shared state across test processes: lock, half-made copy cleanup, eviction of an older build.link_mux's end tells the link's user by shutting down its end of an in-process pair, which a Windows peer does not hear until the handle closes, and nolink_muxtest runs on Windows. Should that become its own issue?poll(2)per macOS read, with no new thread, timer, queue or notification. Linux and Windows read paths are unchanged (cfg!(target_vendor = "apple")). The mux frame reader sits behind aBufReader, so a frame is not one read per field.Evidence
the_connection_ending_frees_every_streamfailed in 1 of 13, 1 of 81 and 1 of 141 stress iterations (both signatures). A stack sample showed the core's demux thread asleep inrecvfromafter its peer ended.recvafter the peer'sshutdown(SHUT_WR)hung for over 60 s, about once in 4,500 rounds. Apollwait hung 0 times in 48,000 rounds, andclose()0 times in 18,000.a_shutdown_ends_the_peers_blocked_read_every_timehung in recvfrom on its first iteration before the fix. Its rounds now run in an owned exact-test subprocess bounded to 60 s. With the macOSpollremoved again, it failed at stress iteration 12 (round 3,724) in 10 s, with the subprocess reaped. With the fix: 75 runs × 5,000 rounds passed, and thelink_muxtests passed 300 of 300 stress iterations (before the drain's failure-path change, which only touches a timeout).device_bootstrappassed 6 of 6 twice locally at 8 threads (macOS, private sshd and pinned Herdr 0.9.5). The store held one stripped copy, rebuilt once when the build changed.hide-platform+hided(lib andit) 971 tests andherdr-core+hide-herdr-client3,496 tests passed on macOS with the change. Clippy-D warningsand fmt are clean.os contract (windows)showed that a Windows shutdown never reaches the peer (CancelIoExends this end's own I/O; the peer hears the end when the handle closes).wsl_device.rsis Windows-only; a cross-check from macOS could not build its C dependencies, so thewindows wsllane is its first compile.recvvspoll+recvon one socketpair (macOS 15.1, load 18-48), not a product build. 64 B messages × 300,000:recv1.14-5.87 µs per read over 5 completed trials,poll+recv1.61-6.71 µs over 9. The difference within a matched pair was 0.3-1 µs; 2 morerecvtrials hung on the lost wakeup. 16 KiB × 20,000, 6 trials each: 5.7-17.8 µs vs 6.4-16.4 µs, with the pairs disagreeing in sign (noise).docs/PERFORMANCE_TESTING.md's matched idle/driven terminal measurement (scripts/web-shell-measure,MEASURE_SCENARIO=keys: key echo p50/p95, hided CPU and RSS, base a891332 vs this head). It was not run: two release builds do not fit on this Mac's disk now, and its load is 20-60. The microbenchmark does not prove the product's end-to-end cost.core_moveandremote_deliverywith the shared helper (left to the remote mailbox lane).Verification record