Skip to content

Wake the owner watch reader through a polled channel - #448

Merged
yansfil merged 1 commit into
mainfrom
fix/ownerwatch-wake
Oct 5, 2026
Merged

yansfil merged 1 commit into
mainfrom
fix/ownerwatch-wake

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: Fixes #446. The 30 s hang limits in the process.rs tests are in #434.

Summary

A guarded child that had finished its work could stay alive on macOS under load, in the drop of its OwnerWatch.
The watch's reader waited in read and relied on a socket shutdown or a 25 ms receive timeout to end; neither woke it.
The reader now polls the owner channel and a wake channel together, and closing the watch wakes it by data and end of stream, then joins.
No time or socket-shutdown behavior is involved any more.

Review

  • 판단해 주세요: 없음. 방향은 #446에서 승인된 것(LocalListener::accept와 같은 wake 채널 패턴)입니다.
  • 조심해서 볼 파일: hide-platform/src/process.rs - owner 상실을 처리하는 reader의 failure path입니다.
    • 닫는 중인 watch는 같은 순간의 owner 종료보다 우선합니다.
    • 읽을 데이터가 있어도 EOF가 아니면 owner 상실로 보지 않습니다.
    • poll 오류는 owner 상실(_exit(125))로 갑니다. 이전 read 오류와 같은 처리입니다.
  • 비용 검토: reader는 이전처럼 스레드 하나이고, 25 ms마다 깨던 수신 타임아웃이 없어져 대기 중 깨어남이 0이 됩니다. 추가 fd는 watch당 socketpair 하나(close에서 해제)입니다.

Evidence

  • 확인한 것:
    • 결정적 회귀 테스트 closing_the_watch_wakes_a_reader_that_is_waiting_on_a_silent_owner: owner 끝이 연결된 채 조용한 상태에서 reader가 poll에 들어간 것을 확인한 뒤 watch를 닫고, join이 wake로 끝나는지 봅니다. 두 번 돌려 admission slot이 반환되는지도 봅니다. 순서는 테스트가 정하고 시간은 hang 한도로만 씁니다. 이 테스트는 한가한 기계에서는 수정 전 코드도 통과합니다(원인이 OS 동작이라서). 수정의 증거는 아래 부하 측정입니다.
    • 부하(taskpolicy -b + yes 4개, 주변 load 25-30) 하에서 같은 테스트를 수정 전/후 바이너리로 비교(8초 안에 안 끝나면 hang): only_a_guarded_launch_returns_startup_proof 수정 전 2/120 hang, 수정 후 0/120. repeated_guarded_work_releases_children_and_capture_resources 수정 전 2/100, 수정 후 0/100. guarded_capture_keeps_stdin...은 양쪽 0/100(재현되지 않은 항목).
    • hide-platform 전체, hide-host, hide-agent-hooks 테스트, fmt-check, clippy -D warnings 통과.
  • 확인하지 못한 것:
    • 수정 전 hang이 왜 shutdown과 수신 타임아웃으로 안 깨졌는지는 끝내 확정하지 못했습니다. 이 수정은 그 OS 동작에 기대지 않는 쪽으로 바꾼 것입니다.
    • 이 hang은 부하가 높을 때만 재현돼서 hang 횟수가 작습니다(합계 수정 전 4, 수정 후 0).
    • Linux와 Windows CI는 돌리지 못했습니다. Windows 구현은 reader가 없어서 바뀌지 않았습니다.
    • 머지 후 macOS CI에서 process.rs 테스트가 안정적인지는 #434와 이 PR이 둘 다 들어간 뒤에 봐야 합니다.

@yansfil
yansfil merged commit 1cab7c3 into main Oct 5, 2026
28 checks passed
@yansfil
yansfil deleted the fix/ownerwatch-wake branch October 5, 2026 04:09
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.

A guarded child can hang in OwnerWatch drop on macOS

1 participant