Skip to content

Claude Code enters unrecoverable CPU spin after MCP tool response #36729

Closed as not planned

Description

@synman

Bug Description

Claude Code enters an unrecoverable 100% CPU spin after receiving a normal MCP tool response. The process becomes completely unresponsive — Ctrl-C, Esc, and all input are ignored. Only kill -9 terminates it. Zombie child processes are left unreaped.

Environment

  • Claude Code version: Latest (installed via claude update on 2026-03-19)
  • OS: macOS (Apple Silicon, Darwin 25.3.0)
  • Shell: zsh
  • Model: claude-opus-4-6 (1M context)

Reproduction

  1. Start a Claude Code session with a custom MCP server providing tools
  2. During conversation, invoke an MCP tool that returns a well-formed JSON response (~2758 bytes, ~4 objects)
  3. The MCP tool completes successfully and returns data to Claude Code
  4. Claude Code enters CPU spin instead of generating the assistant response

Specific trigger observed: report_proposals(filter="read") MCP call returned 2758 chars of valid JSON (4 proposal objects). The tool result was received successfully but the runtime never generated a response.

Observed Behavior

  • Duration: ~11.5 hours of sustained 100% CPU before manual kill (started 12:47 AM, killed 12:09 PM EDT on 2026-03-20)
  • Process state: R+ (running, foreground) — pure CPU spin, not I/O blocked
  • Input: Ctrl-C and Esc completely non-responsive
  • Session ID: 6b7a00f4-8d44-4adc-8e22-495502c64cbe
  • Zombie children: Two child processes (node workers) were never reaped after parent was killed

Expected Behavior

Claude Code should either:

  1. Generate a response after receiving the MCP tool result, or
  2. Time out and surface an error to the user, or
  3. Remain responsive to Ctrl-C/Esc for graceful termination

Additional Context

  • The MCP response was well-formed JSON, not truncated or malformed
  • This is not the first hang observed — Agent subagent calls have also hung with no timeout/recovery mechanism
  • No custom hooks or scripts were executing at the time — the hang occurred in the Claude Code runtime itself during response generation
  • The session transcript (JSONL) shows the MCP tool result was the last entry before the hang

Impact

  • 11.5 hours of wasted compute
  • Required manual process investigation and kill -9
  • Zombie processes left on system requiring cleanup
  • No built-in detection, timeout, or recovery mechanism exists in Claude Code

Activity

  1. github-actions commented on Mar 20, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] Claude Code v2.1.9 Complete Freeze - 100% CPU, Main Thread Stuck in Infinite Loop (macOS ARM64) #18532
    2. Tool calls (WebFetch) can hang indefinitely with no timeout, causing permanent process stall #34565
    3. [BUG] Claude Code hangs indefinitely on large MCP tool responses without user feedback #36469

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. synman commented on Mar 20, 2026

    @synman
    Author
  3. synman commented on Mar 20, 2026

    @synman
    Author

    Dupe Assessment — These Are Different Bugs

    I've analyzed all three tagged potential duplicates. They share the symptom (hang/freeze) but have different root causes:

    #18532 — Closest match (same class)

    100% CPU infinite loop, R+ state, kill -9 required, macOS ARM64. This is the same class of bug — the runtime enters a CPU spin and becomes unresponsive. My issue adds a new reproduction path: the hang occurs after a normal MCP tool response is fully received (proven by JSONL transcript forensics).

    #34565 — Different bug (tool never returns)

    A WebFetch call that never returns — the hang is waiting for I/O. In my case, the MCP tool did return (2758 bytes of valid JSON written to transcript). The CPU spin started during response generation, not during tool execution. Different failure point entirely.

    #36469 — Different bug (oversized response)

    Hang triggered by a large Figma MCP response that exceeds processable size. My trigger was a 2758-byte response (~4 JSON objects) — trivially small. The response content is not the issue.

    Forensic Evidence

    The JSONL session transcript (6b7a00f4) proves the exact failure sequence:

    1. MCP call report_proposals(filter="read") was issued
    2. The tool result (2758 bytes, valid JSON) was received and written to the transcript
    3. No assistant response was ever generated (no subsequent line in transcript)
    4. Process entered R+ state (CPU spin, not I/O wait) at 100% for 11.5 hours
    5. Two zombie child processes (never reaped by parent)
    6. Ctrl-C and Esc completely non-functional

    The hang is in the response generation phase of the Claude Code runtime — after receiving valid input, before producing output. This is distinct from both "tool never returns" (#34565) and "oversized response" (#36469).

    Context payload at time of hang

    Component Size
    Rules/system prompt ~123 KB
    Tool definitions (~135 tools) ~135 KB
    Conversation history (23 tool results) ~93 KB
    System reminders (per-turn injections) ~20-30 KB
    Estimated total API payload ~580-600 KB

    This is well within the 1M context window. The payload size may be a contributing factor but the response itself was small and well-formed.

    Request

    Please don't auto-close this as a duplicate. It provides the most precise diagnostic data of any issue in this class:

    • Exact JSONL transcript proving the tool result was received
    • Process state forensics (R+, zombie children, CPU time)
    • Cumulative API payload measurements
    • Clear proof the hang is in response generation, not tool execution

    This narrows the search space for the underlying runtime bug significantly.

    Cross-reference: Detailed forensics also posted on #18532 (the oldest open issue in this class).

  4. fortunexbt commented on Apr 15, 2026

    @fortunexbt

    @synman this is one of the nastiest unattended-runtime failure modes I have seen — the MCP tool response was valid, the session received it, and then Claude just spins at 100% CPU for 11+ hours with zero recovery path. No timeout, no heartbeat, no Ctrl-C escape. Only kill -9.

    That is exactly the class of failure that makes headless agent automation untrustworthy. The tool did its job; the runtime poisoned itself afterward.

    Are you more blocked by not having a programmable timeout that kills a stuck session before it burns a full day of compute, or by not having runtime health signals that would let an operator detect the spin automatically and intervene?

    I am building PicoMUTX around exactly this operator-control gap and happy to compare notes if useful.

  5. synman commented on Apr 15, 2026

    @synman
    Author

    Fortunately this was just pure cpu spin on a single core so it didn't consume tokens / etc

  6. oviron commented on Apr 21, 2026

    @oviron

    Reproducing #36729 on v2.1.114 — 100% CPU spin after parallel sub-agent MCP responses

    Adding a fresh reproduction of this bug. Identical symptoms, three simultaneous occurrences on the same machine in 48h.

    Environment

    • Claude Code version: 2.1.114 (running); 2.1.116 installed (auto-updated while hung session continued)
    • OS: macOS 26.4.1 (Darwin 25.4.0) ARM64
    • Shell: zsh
    • Model: Opus 4.7 (1M context)
    • Flag used: --dangerously-skip-permissions

    Trigger

    User-invoked custom skill /research, which spawned one general-purpose sub-agent. Sub-agent issued 4 parallel mcp__tavily__tavily_search calls and entered thinking with high effort. At ~2m 2s / ~2.3k tokens of the thinking phase, main Claude Code locked up.

    Observations

    • Main process in R+ state, 100% CPU, for 12h 46m before manual kill
    • Ctrl-C, Esc completely unresponsive; terminal couldn't even be scrolled
    • `sample` shows all time burned on `com.apple.main-thread` DispatchQueue — single-threaded busy loop, no syscalls, no blocked I/O
    • Zero open network sockets (unlike healthy sibling sessions that keep TLS to `160.79.104.10`) — HTTP work was already done
    • One zombie child reaped nowhere: PID 27203 (the sub-agent worker) in `Z+` state, parent PID = hung main
    • Session directory contains only the `SessionStart` hook stdout — no tool-call records, no message records were persisted before the hang

    Three earlier hangs from the same machine

    Pattern is not a one-off. At the time of investigation three older hung sessions were still live:

    PID ELAPSED CPU time Accumulated zombie children
    39309 1d 00h 319 min 8
    40140 1d 19h 1489 min 8
    42460 1d 19h 1462 min 8
    59147 12h 46m 766 min 1 (growing)

    Combined ~68 hours of wasted compute. All four had identical `R+` / 100% CPU / zombie-children signature. Only `kill -9` terminated them.

    Hypothesis

    Sub-agent exits cleanly (hence zombie in parent), writes its final message to the pipe, but main-thread parser/harmonizer enters an infinite loop on the response. Matches the harmonizing-step hang in #21399 and the JSON-serialization hang in #4580.

    Trigger combination: parallel MCP tool calls inside a sub-agent + extended thinking (`high effort`). Removing parallelism (sequential MCP calls) appears to avoid it.

    Would be helpful

    1. Watchdog timer on response-generation phase that surfaces a `kill -9` hint after N minutes of 100%-CPU + no output
    2. Reap `SIGCHLD` regardless of hang state — accumulated zombies make `ps` noisy and hide live state
    3. Re-test path: one sub-agent + ≥3 parallel MCP calls + `thinking="high"` on Opus 4.7 — very reproducible here

    Happy to attach a `sample` trace from the live hung process if it helps.

  7. nestorcolt commented on Apr 29, 2026

    @nestorcolt

    same problem here even opus 46 - 47 anbd the latest cc 2.1.123 (Claude Code)

  8. github-actions commented on May 30, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  9. github-actions commented on Jul 31, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  10. locked as resolved and limited conversation to collaborators on Jul 31, 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

    area:mcpbugSomething isn't workinghas reproHas detailed reproduction stepsperf:cpuplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions