[Bug] Infinite recursion in terminal text rendering causes high CPU usage

Resolved 💬 2 comments Opened Jan 31, 2026 by enki Closed Jan 31, 2026

Bug Description
Claude Code Debugging a sample of 2.1.27 eating lots of CPU:

⏺ Summary

Based on the deep analysis, here's exactly what's happening:

The Bug

Claude Code has a recursion bug in its terminal text rendering code (function at offset 0x1c93a20). This
function is likely responsible for:

  • Calculating text width for line wrapping
  • Processing ANSI escape sequences
  • Handling Unicode character widths
  • Or formatting markdown/code blocks

The Call Flow

User input/API response arrives
→ Bun runtime processes it
→ Claude Code rendering logic kicks in
→ Terminal formatter prepares output
→ Text processing function (0x1c93a20) is called
→ INFINITE RECURSION - calls itself 100+ times
→ Eventually writes to terminal
→ CPU burns at 22% just in this one function

What Likely Triggered It

Something in the conversation (your text, Claude's response, a code block, etc.) contains an edge case
that breaks the recursion termination logic. Common triggers:

  1. Very long line with no good wrap points (like a massive URL or hash)
  2. Deeply nested formatting (markdown in markdown in markdown...)
  3. Special Unicode characters (zero-width joiners, combining marks, emoji variants)
  4. Malformed ANSI codes that confuse the parser
  5. Circular reference in the formatting state machine

Why It's Bad

  • 22% of CPU in ONE recursive function
  • 100+ stack depth = hundreds of KB of stack memory
  • Blocks the UI thread = frozen terminal
  • Burns battery and heats up machine

This is 100% a bug in Claude Code itself that Anthropic needs to fix. The specific trigger is whatever
content was being rendered when you took this sample.

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.1.27
  • Feedback ID: 06083162-d0f0-4523-97b0-0f2ccc330233

Errors

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/paul/.local/share/claude/versions/2.1.27 (expected in multi-process scenarios)\n    at DUR (/$bunfs/root/claude:3589:2098)\n    at jPA (/$bunfs/root/claude:3589:1209)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-01-31T03:54:45.126Z"},{"error":"Error: Request was aborted.\n    at makeRequest (/$bunfs/root/claude:360:3940)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-01-31T04:02:37.338Z"}]

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗