Skip to content

drop한 lock이 다른 thread가 시작한 child에 남아 0초 대기 claim이 바쁜 lock으로 실패한다 #820

Closed

Description

@yansfil

What happened

hide-agent-hooks의 delivery::tests::diagnostic_claim_precedes_output_and_repeated_cause_is_suppressed가 2026-10-09 이 Mac에서 bash scripts/verify-cargo.sh test-scoped -p hide-platform -p hide-agent-hooks -p hide-kit 중 한 번 실패했고(load 7-15), 같은 테스트만 다시 돌리자 통과했습니다.
실패한 줄은 hide-agent-hooks/src/delivery.rs:303, 같은 HOME에서 앞의 cli claim 다음에 오는 assert!(diagnose(home.path(), "deadline"))입니다.

확인한 것:

  • delivery::claim은 delivery-diagnostics.lock을 Duration::ZERO(한 번만 시도)로 잡고, 잡지 못하면 false를 돌려줍니다.
  • hide_platform::fs::lock::Lock은 drop할 때 descriptor를 닫기만 하고 lock을 명시적으로 풀지 않습니다. Unix에서 flock은 open file에 붙으므로, 그 사이 다른 thread가 fork한 child가 descriptor 사본을 쥐고 있으면 그 child가 exec할 때까지 lock이 남습니다. hide-platform/src/fs/lock.rs의 모듈 문서가 이 동작을 적어 두었습니다.
  • hide-platform/tests/it/fs.rs는 같은 현상 때문에 drop 뒤 lock을 다시 잡을 때 RELEASED_WITHIN(10초)까지 기다립니다.

추정(확인하지 않음):

  • 실패한 순간 같은 test binary의 다른 thread(예: codex_daemon 테스트가 stand-in codex를 실행)가 앞 claim의 lock을 쥔 채 fork해, 다음 claim의 한 번 시도가 바쁜 lock을 만났습니다.
  • 제품에서도 같은 일이 생길 수 있습니다. 같은 프로세스의 다른 thread가 child를 시작하는 순간 drop된 lock은 잠시 남고, 0초 대기로 lock을 시도하는 쪽은 그것을 다른 holder로 읽습니다.

What you expected

drop한 lock은 그 즉시 풀리고, 다른 thread가 그 순간 시작한 child가 lock을 들고 있지 않습니다.

Steps to reproduce

  1. 다른 build가 돌아 부하가 있는 macOS에서 bash scripts/verify-cargo.sh test-scoped -p hide-agent-hooks를 여러 번 실행합니다.
  2. 드물게 delivery::tests::diagnostic_claim_precedes_output_and_repeated_cause_is_suppressed가 delivery.rs:303에서 실패합니다.

Versions

Diagnostics

thread 'delivery::tests::diagnostic_claim_precedes_output_and_repeated_cause_is_suppressed' panicked at hide-agent-hooks/src/delivery.rs:303:9
test result: FAILED. 136 passed; 1 failed

Activity

  1. added
    bug
    on Oct 8, 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