Panic: UTF-8 byte boundary errors when rendering CJK text
Resolved 💬 7 comments Opened Dec 21, 2025 by alterxyz Closed Feb 21, 2026
Bug Description
Claude Code CLI crashes with Rust panics when rendering content containing Chinese (CJK) characters. Multiple crashes at different string positions indicate a systemic UTF-8 handling issue.
Error Messages
Crash 1:
thread '<unnamed>' panicked at library/core/src/str/mod.rs:833:21:
byte index 11 is not a char boundary; it is inside '职' (bytes 9..12)
fatal runtime error: failed to initiate panic, error 5, aborting
zsh: abort claude
Crash 2:
thread '<unnamed>' panicked at library/core/src/str/mod.rs:833:21:
byte index 4 is not a char boundary; it is inside '里' (bytes 2..5)
fatal runtime error: failed to initiate panic, error 5, aborting
zsh: abort claude
Analysis
- Both crashes occur at Rust's
str::mod.rs:833(string slicing) - Different Chinese characters trigger the panic at different byte positions
- This indicates a common text truncation/display function has the bug
- The issue appears during CLI startup when processing CLAUDE.md
Root Cause
Byte-based string slicing without checking UTF-8 character boundaries. CJK characters are 3 bytes in UTF-8, so byte-index slicing frequently lands mid-character.
Reproduction
- Create a CLAUDE.md containing Chinese text (especially in markdown tables)
- Run
claudein the directory - CLI crashes during startup or conversation
Environment
- OS: macOS Darwin 24.6.0
- Claude Code: Latest version
Suggested Fix
Use character-aware string operations:
.chars().take(n)instead of&s[..n]- Check
s.is_char_boundary(n)before slicing - Use
s.floor_char_boundary(n)(Rust 1.80+) for safe truncation
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗