CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoning
Man Ho Lam, Chaozheng Wang, Jen-tse Huang, Michael R. Lyu
TL;DR
CodeCrash presents a comprehensive robustness benchmark for LLM-driven code reasoning under NL-embedded perturbations by integrating CruxEval and LiveCodeBench. It introduces perturbation families—PSC-ALL (aggregated structural changes), MCC/MPS (contextual NL cues), and MHC (reasoning-level hints)—to stress-test executable semantics and measure Pass@1 across 17 models. The study reveals a substantial average degradation of $23.2\%$, with PSC-ALL and NL cues driving the majority of drops, and shows that Chain-of-Thought (CoT) reduces degradation to $13.8\%$ on average but cannot fully mitigate vulnerability; LRMs demonstrate strong robustness yet exhibit token-explosion and “Reasoning Collapse” in extreme cases. Overall, CodeCrash provides a rigorously-defined framework for evaluating and guiding the development of more reliable code reasoning models, highlighting fundamental limitations in distinguishing code semantics from noisy NL cues and the need for defenses beyond prompt-based strategies.
Abstract
Large Language Models (LLMs) have recently demonstrated strong capabilities in code-related tasks, but their robustness in code reasoning under perturbations remains underexplored. We introduce CodeCrash, a stress-testing framework with 1,279 questions from CruxEval and LiveCodeBench, designed to evaluate reasoning reliability under structural perturbations and misleading natural language (NL) contexts. Through a systematic evaluation of 17 LLMs, we find that models often shortcut reasoning by over-relying on NL cues, leading to an average performance degradation of 23.2% in output prediction tasks. Even with Chain-of-Thought reasoning, models on average still have a 13.8% drop due to distractibility and rationalization, revealing a lack of critical reasoning capability to distinguish the actual code behaviors. While Large Reasoning Models with internal reasoning mechanisms improve robustness by fostering critical thinking, plausible yet incorrect hints can trigger pathological self-reflection, causing 2-3 times token consumption and even catastrophic cognitive dissonance in extreme cases for QwQ-32B. We refer to this phenomenon as Reasoning Collapse. CodeCrash provides a rigorous benchmark for evaluating robustness in code reasoning, guiding future research and development toward more reliable and resilient models.
