[BUG] Rust panic on UTF-8 character boundary when editing files with Chinese text

Resolved 💬 3 comments Opened Dec 24, 2025 by PANXIONG-CN Closed Dec 27, 2025

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?

Bug Description

Claude Code crashes with a Rust panic when processing LaTeX files containing Chinese characters.

Environment

  • Claude Code Version: 2.0.76
  • Platform: Linux (WSL2) 6.6.87.2-microsoft-standard-WSL2
  • File Type: LaTeX (.tex) with Chinese content
  • Model: claude-opus-4-5-20251101

What Should Happen?

processing LaTeX files containing Chinese characters without erros

Error Messages/Logs

thread '<unnamed>' (2855) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 75 is not a char boundary; it is inside ',' (bytes 73..76) of `卡并行可缩短至15小时,项目期间预计进行10轮训练优化,累计约`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
Aborted (core dumped)

Steps to Reproduce

  1. Open a LaTeX project containing Chinese text
  2. Use Claude Code to edit the .tex file
  3. The crash occurs during/after file modification when the tool attempts to display or process strings containing multi-byte UTF-8 characters (Chinese punctuation like which is 3 bytes)

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

Root Cause Analysis

The error indicates a string slicing issue at byte boundaries:

  • Chinese comma occupies bytes 73-76 (3 bytes in UTF-8)
  • Code attempts to access byte index 75, which is in the middle of the character
  • This violates Rust's string safety requirements, causing a panic

Suggested Fix

The Rust code performing string operations needs to use character-aware methods:

  • Use str::char_indices() instead of byte indexing
  • Use str::chars() for iteration
  • Ensure any substring operations respect character boundaries

Workaround

Currently, users can:

  1. Retry the operation (sometimes succeeds)
  2. Ask Claude to output text suggestions instead of direct file edits
  3. Manually apply changes in an external editor

View original on GitHub ↗

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