Skip to content

A guarded child can hang in OwnerWatch drop on macOS #446

Closed

Description

@yansfil

What happened

On macOS, hide-platform/tests/process.rs guarded-launch tests fail with CaptureError { kind: Deadline } although the child already printed its result.
A guarded child that has finished its work stays alive in OwnerWatch drop, so the owner's capture runs into its deadline and cleanup reports TimedOut.

CI evidence:

Local measurement (macOS 15, taskpolicy -b plus 4 yes, ambient load average 40-80):

  • The test failed about 1 run in 20 with a 1850 ms deadline and still failed with a 30 s deadline, so the child hangs rather than starts slowly.
  • A hung child sampled at 9-11 s was in state SN with CPU time 0:00.01.
    Its stack was child_role -> drop of OwnerWatch -> OwnerWatch::close_inner -> JoinHandle::join -> _pthread_join, while the owned-child-watch reader thread stayed in UnixStream::read -> __recvfrom.
  • close_inner sets cancelled, calls channel.shutdown(Both), then joins.
    Neither the shutdown nor the reader's 25 ms SO_RCVTIMEO woke the reader for 11+ s.
  • With the ambient load back to 13 it no longer reproduced (0 in 520 runs), so it depends on a loaded machine.

What you expected

Dropping an OwnerWatch ends its reader promptly on every system, without relying on how the operating system delivers a shutdown or a receive timeout.

Steps to reproduce

  1. Build the hide-platform process test binary on macOS.
  2. Start 4 yes processes and run taskpolicy -b <process-test-binary> only_a_guarded_launch_returns_startup_proof --exact repeatedly, on a machine whose load average is already high.
  3. Sample a child_role process that is older than 9 s.

Not reproducible on an idle machine.

Versions

  • hide: main at 59d13d9
  • macOS: 15.1 (local), macos-15 (CI)

Diagnostics

Fix direction (approved): the reader polls the socket and a wake channel together, and drop wakes it and then joins, the pattern LocalListener::accept already uses.
The regression test orders the events itself: it waits until the reader is inside its poll, drops the OwnerWatch, and checks that the join ends by the wake.

Activity

  1. added
    bug
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions