anthropics / anthropics/claude-code

Headless claude -p deadlocks in uninterruptible openat on macOS; interactive sessions unaffected

未关闭
#89,272 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:cli area:core bug has repro platform:macos
主要语言
Python
星标
145k
派生
23.1k
PR 合并指标
PR 指标待抓取

描述

**Date:** 2026-08-24

## Summary
Every headless invocation (`claude -p`) on this machine deadlocks partway into the session:
main thread blocked forever in `openat$NOCANCEL`, 0% CPU, no TCP connections, no child
processes. Interactive sessions on the same machine, same account, are unaffected.
8/8 reproductions: 5 via a no-mistakes pipeline daemon spawning `claude -p --output-format
stream-json --json-schema ... --dangerously-skip-permissions`, and 3 spawned directly from a
shell with stdout redirected to a file (with and without `--debug`, with and without
`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`).

## Signature
- `sample `: main thread parked in `openat$NOCANCEL` (1500+/1500+ samples), JIT (JS)
frames above; worker threads idle in `kevent64`/pool waits.
- No TCP sockets open (`lsof`); not a network hang.
- No child processes; not a tool-subprocess hang.
- `SIGKILL` sometimes fails to reap the process (uninterruptible syscall).
- Freeze point varies by run: after ~2 tool rounds (transcript event 19, last =
`total_tokens_reminder` attachment), at `ai-title` (event 9), or at `atis-latch` (event 20).
Always coincides with concurrent background activity (session-title request in flight,
statsig/bootstrap fetch, atomic `~/.claude.json` rewrite).
- With `--debug`: log stops mid-stream right after two concurrent `/v1/messages` requests
(`source=generate_session_title` + `source=sdk`) both received first bytes.

## Ruled out
- no-mistakes daemon (reproduces with plain `claude -p` from a shell)
- claude version regression (2.1.235 and 2.1.241 both freeze)
- permission-prompt deadlock (`--dangerously-skip-permissions` present in pipeline repros)
- stdout backpressure (reproduces with stdout redirected to a regular file)
- hung file provider (Google Drive + fileproviderd restarted; CloudStorage lists fine)
- FIFOs / dead symlinks in cwd, skills, agents, plugins trees (none exist)
- keychain-db file locks (no holders)
- nonessential traffic (`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` still freezes)

## Not yet done (needs sudo)
`fs_usage`/`spindump` or lldb attach to capture the blocked path argument — lldb attach is
denied by SIP for a same-user attach on this machine.

## Repro
```
cd
echo 'Read README.md, then read pyproject.toml, then reply with one sentence.' | claude -p
# hangs forever; sample the pid to see openat$NOCANCEL
```

## Impact
Any local tooling that drives `claude -p` (review pipelines, cron jobs, CI-style local gates)
wedges silently. Workaround in use: pipeline agent switched to codex; Claude review still
applied via GitHub Actions (claude-review.yml) and interactive sessions.

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start with the `claude -p` reproduction command from any Git repository and capture `--debug` output alongside `fs_usage`, `spindump`, or an lldb attach as described. Compare the headless path with the interactive session and the `claude-review.yml` workflow; done means the reported macOS invocation no longer deadlocks in `openat$NOCANCEL`.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, macos
领域
cli, operating-systems
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
活跃
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。