[BUG] export` Command Crashes on Emoji Characters (UTF-8 Boundary Error)
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?
---
title: Claude Code Bug Report Export Crash
type: guide
component_type: guide
version: 1.0.0
audience: contributor
status: draft
summary: Auto-classified guide document
keywords:
- guide
tokens: ~1000
created: '2026-01-11'
updated: '2026-01-11'
tags:
- guide
---
Bug Report: /export Command Crashes on Emoji Characters (UTF-8 Boundary Error)
Summary
The /export command in Claude Code panics with a fatal runtime error when the conversation contains certain emoji characters. The crash occurs due to incorrect UTF-8 string slicing at a non-character boundary.
Environment
| Component | Value |
|-----------|-------|
| Claude Code Version | 2.1.4 |
| Platform | macOS (Darwin 25.2.0) |
| Architecture | arm64 (Apple Silicon) |
| Kernel | xnu-12377.61.12~1/RELEASE_ARM64_T8132 |
Error Message
thread '<unnamed>' panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 2 is not a char boundary; it is inside '✅' (bytes 0..3) of `✅`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
[1] 14209 abort claude
Steps to Reproduce
- Start a Claude Code session in a project containing CLAUDE.md files with emoji characters (specifically
✅,❌, or similar multi-byte emojis) - Have a conversation that includes or references content with these emojis
- Run the
/exportcommand - Result: Claude Code crashes with the above panic message
Minimal Reproduction
The crash appears to be triggered when /export processes text containing the ✅ emoji (U+2705, 3 bytes in UTF-8: 0xE2 0x9C 0x85).
The error indicates the code attempts to slice the string at byte index 2, which falls in the middle of the 3-byte emoji sequence.
Frequency
- Highly reproducible - 12 crashes observed in a single session
- Crash occurs consistently when emoji content is present
- Sometimes
/exportsucceeds on retry (possibly different code path or content ordering)
Root Cause Analysis
The panic occurs in Rust's standard library string slicing code (str/mod.rs:833). This indicates:
- Code is attempting to slice a
&strat a byte index that is not a valid UTF-8 character boundary - The
✅emoji occupies bytes 0-2 (3 bytes total) - The code tries to slice at index 2, which is inside the emoji
- Rust panics because this would create an invalid UTF-8 string
Likely Code Pattern Causing the Bug
// INCORRECT - causes panic on multi-byte characters
let truncated = &text[0..2]; // Panics if byte 2 is mid-character
// CORRECT - respects character boundaries
let truncated: String = text.chars().take(2).collect();
// OR
let truncated = &text[..text.char_indices().nth(2).map_or(text.len(), |(i, _)| i)];
Confirmed Crash-Causing Emoji
The specific emoji causing the crash is ✅ (White Heavy Check Mark, U+2705).
The error message explicitly identifies this:
byte index 2 is not a char boundary; it is inside '✅' (bytes 0..3) of `✅`
UTF-8 Byte Analysis
Character: ✅ (U+2705)
UTF-8 bytes: E2 9C 85 (3 bytes)
↑ ↑ ↑
0 1 2 ← byte indices
Attempted slice at index 2 → INVALID (mid-character)
The code attempts to slice the string at byte index 2, which lands on 0x85 - the third byte of the 3-byte emoji sequence. This creates an invalid UTF-8 string, triggering the panic.
Other Potentially Affected Emojis
Any multi-byte emoji could trigger this bug if the slicing logic encounters it:
| Emoji | Unicode | UTF-8 Bytes | Risk |
|-------|---------|-------------|------|
| ✅ | U+2705 | 3 bytes | CONFIRMED |
| ❌ | U+274C | 3 bytes | High (similar encoding) |
| ✓ | U+2713 | 3 bytes | Present |
| ⚠️ | U+26A0 + FE0F | 3+ bytes | Present |
| 🎯 | U+1F3AF | 4 bytes | Present |
| 📁 | U+1F4C1 | 4 bytes | Present |
| 🤖 | U+1F916 | 4 bytes | Present |
| ⚙ | U+2699 | 3 bytes | Present |
| 💻 | U+1F4BB | 4 bytes | Present |
Workarounds
- Use
/export <name>- Providing a name sometimes avoids the crash (different code path?) - Retry - The command occasionally succeeds on subsequent attempts
- Remove emojis - Temporarily remove emoji characters from CLAUDE.md files before exporting
Impact
- Severity: Medium-High
- User Impact: Cannot reliably export conversation history
- Data Loss Risk: Session context may be lost if user cannot export before session ends
Session Data
- Session ID:
bf209d5d-c70f-4f42-85a7-bfb0eb16c8f8 - Crash Count: 12 occurrences in single session
- Session Size: 257KB at time of crashes
- Project: Contains 3 CLAUDE.md files with emoji content
Suggested Fix
The fix should ensure all string slicing operations in the export functionality use character-aware methods rather than byte indexing. Specifically:
- Audit all
&str[start..end]operations in export code path - Replace with character-boundary-safe alternatives:
- Use
.chars()iterator for character-based operations - Use
.char_indices()for finding valid slice points - Use crates like
unicode-segmentationfor grapheme-aware slicing
- Add tests with multi-byte Unicode characters (emojis, CJK, etc.)
Additional Context
The crash message shows the panic handler itself failed (failed to initiate panic, error 5), suggesting this might be happening in a thread or context where normal panic handling is compromised.
Related
- Rust book: Slicing Strings
- Similar issues in other Rust projects with UTF-8 string handling
---
Reported: 2026-01-11
Reporter: Hal Casteel
What Should Happen?
claude code should not crash
Error Messages/Logs
hread '<unnamed>' (6264027) panicked at
/rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core
/src/str/mod.rs:833:21:
byte index 2 is not a char boundary; it is inside '✅'
(bytes 0..3) of `✅`
note: run with `RUST_BACKTRACE=1` environment variable to
display a backtrace
fatal runtime error: failed to initiate panic, error 5,
aborting
[1] 14209 abort claude
Steps to Reproduce
hread '<unnamed>' (6264027) panicked at
/rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core
/src/str/mod.rs:833:21:
byte index 2 is not a char boundary; it is inside '✅'
(bytes 0..3) of ✅
note: run with RUST_BACKTRACE=1 environment variable to
display a backtrace
fatal runtime error: failed to initiate panic, error 5,
aborting
[1] 14209 abort claude
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude Code v2.1.4 Opus 4.5 Claude Max
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗