[BUG] Complete UI freeze during Bash tool execution - Thread deadlock
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code completely freezes during Bash tool execution. The timer stops updating, Esc
doesn't interrupt, and no keyboard input is possible. The process must be killed with
kill -9 (SIGTERM is ignored).
This issue started occurring a few days ago and happens irregularly - sometimes every
few minutes, sometimes every few hours. Any Bash command can trigger it.
What Should Happen?
Timer should continue counting
- Esc should interrupt the request at any time
- UI should remain responsive during Bash execution
Error Messages/Logs
No error messages - the UI freezes completely.
Thread state analysis via /proc/<pid>/task/*/wchan:
- Main thread: ep_poll (waiting for epoll events)
- Worker threads: 18x futex_wait_queue (blocked on mutex)
- I/O thread: wait_woken
Process shows State: R (running) but event loop never executes.
Process ignores SIGTERM, only responds to SIGKILL.
Steps to Reproduce
- Start Claude Code
- Execute any Bash tool command
- The UI may freeze completely at random
- The status line stops updating (timer stuck)
- Pressing Esc does nothing
- No keyboard input possible
- Process ignores SIGTERM - must be killed via
kill -9 <pid>
Specific trigger: Serial port access reliably triggers the freeze:
stty -F /dev/ttyUSB0 115200 raw -echo && timeout 8 cat /dev/ttyUSB0 2>&1 || true
However, the freeze also occurs with non-blocking commands and background workarounds.
Any Bash tool execution can trigger it.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.19 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
## Technical Analysis
This is a thread deadlock, NOT GC thrashing:
- Main thread stuck in ep_poll, waiting for events
- UI thread blocked on futex_wait_queue - waiting for mutex
- One thread holds a lock and is waiting for I/O
- UI thread waits for the same lock → deadlock
### Debug Log Analysis
With --debug flag enabled, the log shows:
- No errors or warnings before the freeze
- Last entries are repeated [ToolSearch:optimistic] lines (20+ identical at same
timestamp)
- Then logging stops completely
- The deadlock occurs synchronously - even the logging thread is blocked
### Key Difference from #19344 (GC Death Spiral)
| Metric | #19344 | This Issue |
|--------|--------|------------|
| CPU | 150-180% | Low |
| Thread state | GC functions | futex_wait_queue |
| Memory | Growing | Stable |
### Additional Evidence
After killing the frozen process:
- Terminal showed buffered keystrokes typed during freeze
- Confirms UI thread was blocked, process alive, input buffered but never read
### Related Issues
- #19344 - different root cause (GC vs deadlock)
- #20572 - similar symptoms, different trigger
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗