Panic in syntect regex: OnigError(-5) memory allocation failure on large MCP tool responses
Resolved 💬 2 comments Opened Feb 17, 2026 by nobiehl Closed Mar 17, 2026
Bug Description
Claude Code crashes with a Rust panic in the syntect syntax highlighting library when rendering large or complex tool responses (e.g., MCP tool output containing decompiled Java source code with escaped Unicode sequences).
Error
thread '<unnamed>' (16132) panicked at /Users/hellja/.cargo/registry/src/artifactory.infra.ant.dev-7db23613d841872b/syntect-5.3.0/src/parsing/regex.rs:70:53:
regex string should be pre-tested: Error(OnigError(-5), fail to memory allocation)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Reproduction Steps
- Connect an MCP server that returns Java source code snippets (e.g., decompiled JDK classes via JDTLS
java/classFileContents) - Call a tool that returns ~50 lines of Java source including Javadoc with HTML entities (
\u003cp\u003e,\u003ci\u003e, etc.) - Claude Code attempts to syntax-highlight the response and crashes
Environment
- OS: Windows 11 Enterprise 10.0.26200
- Shell: PowerShell / Git Bash
- syntect version: 5.3.0 (from error message)
Expected Behavior
Tool responses should render without crashing, even if syntax highlighting fails. A graceful fallback to plain text would be preferable.
Possible Cause
The Oniguruma regex engine (OnigError(-5)) fails to allocate memory when parsing complex content. This could be triggered by:
- Large inline source code in JSON tool responses
- Escaped Unicode sequences in Javadoc comments
- Deeply nested regex patterns in the Java grammar
A catch_unwind around the syntect highlighting call or a memory limit guard could prevent the panic from crashing the entire process.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗