Crash: UTF-8 char boundary panic when handling Chinese characters

Resolved 💬 3 comments Opened Dec 24, 2025 by missish Closed Dec 28, 2025

Bug Description

Claude Code crashes with a Rust panic when processing text containing Chinese characters. The error occurs during a Write operation to CLAUDE.md.

Error Message

thread '<unnamed>' (840682) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 8 is not a char boundary; it is inside '库' (bytes 6..9) of `数据库。`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
[1]    840682 IOT instruction (core dumped)  claude

Environment

  • OS: Debian 12 (WSL2)
  • Kernel: Linux 5.15.167.4-microsoft-standard-WSL2
  • Context: Writing to a CLAUDE.md file containing Chinese text

Steps to Reproduce

  1. Open Claude Code in a project with a CLAUDE.md file containing Chinese characters
  2. Trigger a Write operation to CLAUDE.md
  3. The application crashes with the UTF-8 boundary panic

Root Cause Analysis

The Rust code is attempting to index into a UTF-8 string at byte position 8, but this position falls in the middle of the Chinese character '库' (which occupies bytes 6-9). In UTF-8, Chinese characters typically use 3 bytes each.

The string 数据库。 breaks down as:

  • 数: bytes 0-2
  • 据: bytes 3-5
  • 库: bytes 6-8
  • 。: bytes 9-11

Attempting to slice at byte index 8 causes a panic because it's not a valid character boundary.

Expected Behavior

Claude Code should properly handle UTF-8 character boundaries when processing text containing multi-byte characters (Chinese, Japanese, Korean, emojis, etc.).

Additional Context

This appears to be a string slicing operation that doesn't account for multi-byte UTF-8 characters. The fix likely involves using character-aware string operations instead of byte-based indexing.

View original on GitHub ↗

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