Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation DOI: XXXXXXX.XXXXXXX Price: 15.00 ISBN: 978-1-4503-XXXX-X/18/06 CCS: Software and its engineering Software maintenance tools CCS: Information systems Information integration CCS: Computing methodologies Natu
Mohammad Abdollahi, Khandaker Rifah Tasnia, Soumit Kanti Saha, Jinqiu Yang, Song Wang, Hadi Hemmati · 2025
Read Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation DOI: XXXXXXX.XXXXXXX Price: 15.00 ISBN: 978-1-4503-XXXX-X/18/06 CCS: Software and its engineering Software maintenance tools CCS: Information systems Information integration CCS: Computing methodologies Natu by Mohammad Abdollahi, Khandaker Rifah Tasnia, Soumit Kanti Saha, Jinqiu Yang, Song Wang, Hadi Hemmati (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2512-00215.txt.
Introduction
Large language models can predict what a program will print, but their reasoning on the way there is murky. Mohammad Abdollahi and co-authors study errors inside those reasoning traces in 2025, focusing on code execution simulation. They examine how intermediate states and control flow lead to final results.
Earlier studies mostly compared output accuracy and treated reasoning as a black box. Understanding a program's runtime behavior is essential for reliable code generation, debugging, and automated reasoning. By demystifying where traces go wrong, the study helps developers judge when a model's confident answer rests on broken steps. Code execution is a strict test, because one wrong intermediate value usually ruins the answer.
Catalog record
| CREATOR | Mohammad Abdollahi, Khandaker Rifah Tasnia, Soumit Kanti Saha, Jinqiu Yang, Song Wang, Hadi Hemmati |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 59 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2512-00215
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation DOI: XXXXXXX.XXXXXXX Price: 15.00 ISBN: 978-1-4503-XXXX-X/18/06 CCS: Software and its engineering Software maintenance tools CCS: Information systems Information integration CCS: Computing methodologies Natural language processing CCS: Computing methodologies Artificial intelligence Mohammad Abdollahi, Khandaker Rifah Tasnia, Soumit Kanti Saha, Jinqiu Yang, Song Wang, Hadi Hemmati Abstract . Understanding a program’s runtime reasoning behavior, i.e., how intermediate states and control flows lead to final execution results, is essential for reliable code generation, debugging, and automated reasoning. While large language models (LLMs) have demonstrated impressive capabilities in predicting program outputs, most prior studies have focused on output accuracy and performance comparisons, treating reasoning as a black box. As a result, models often struggle with complex control logic or subtle semantic nuances, and little is known about the structure, quality, or failure modes of their reasoning traces. Recent advances in reasoning LLMs, which explicitly generate intermediate reasoning steps before producing final answers, raise the expectation that models could not only produce correct code but also explain their reasoning in ways consistent with program semantics. This ability is particularly critical for tasks involving runtime behavior, where reasoning must capture both control flow and state changes. However, the lack of systematic evaluation of reasoning traces leaves open fundamental questions about how reasoning errors arise and how they influence execution correctness. To address this gap, we conduct the first empirical study on reasoning runtime behavior inference with reasoning LLMs to systematically uncover and characterize the errors in their reasoning traces. For our research, we curate a benchmark constructed from two widely used datasets (i.e., HumanEval+ and LiveCodeBench), containing 427 code snippets. For each code snippet, we experiment with three different types of inputs, i.e., regular, edge, and invalid inputs. A total of 12 input values are selected per snippet, each paired with its ground-truth execution outcome. We evaluate four state-of-the-art reasoning LLMs, i.e., DeepSeek-R1, OpenAI o4-mini, Gemini 2.5 Flash, and Claude 4 Sonnet, and our experiment results show that the examined reasoning LLMs can achieve high accuracies ranging from 85% to 98% across all three input types. Additionally, we analyzed the errors in reasoning traces produced by LLMs and developed a comprehensive taxonomy encompassing nine categories of inference errors in the code output inference tasks. We further investigate whether a tool-augmented reasoning approach can enhance the reasoning ability of LLMs. Using failures in the Computation Errors category as a case study, our experiments show that this method successfully corrects 58% of such errors, underscoring the promise of tool augmentation in improving LLM reasoning. 1. Introduction Large Language Models (LLMs) have become increasingly capable in software engineering tasks, including code generation, translation, summarization, and reasoning ( Abdollahi et al. 2025 ; Yang et al. 2025b ) . Recent developments in reasoning LLMs, i.e., models that explicitly generate intermediate reasoning traces before producing a final answer, have raised expectations that these systems may not only produce correct code, but also explain their reasoning in a manner that aligns with program semantics ( Guo et al. 2025 ) . This capability is particularly relevant for tasks that require understanding a program’s runtime behavior, i.e., the sequence of operations and state changes that occur during execution ( Gu et al. 2024 ) . Prior work ( Liu et al. 2024 ; Chen et al. 2025 ; Beger and Dutta 2025 ; Tang et al. 2025 ; Xie et al. 2025 ; Yang et al. 2025a ) on assessing LLMs’ capability to reason about the runtime behavior of program execution has predominantly examined performance differences across models. For example, CodeMind ( Liu et al. 2024 ) evaluated a range of LLMs, including both general-purpose and code-specialized models, on code reasoning tasks such as semantic understanding and output prediction. REval ( Chen et al. 2025 ) assessed the reasoning ability and execution consistency of code LLMs, introducing an Incremental Consistency (IC) metric to measure how well a model maintains coherent reasoning across sequential tasks of increasing difficulty. CoCoNut ( Beger and Dutta 2025 ) examined LLMs’ ability to trace program control flow when provided with relevant inputs, offering insights into their understanding of execution behavior. However, these studies largely focused on evaluating LLMs’ output accuracy rather than on analyzing the reasoning traces generated by LLMs on code execution. As a result, little is known about the nature of LLM-generated reasoning traces, the types of errors they contain, and how these errors relate to the underlying program semantics, leaving a critical gap in understanding and improving LLMs’ true reasoning abilities. Figure 1 illustrates a representative example of an LLM-generated reasoning trace for a code execution task. The figure presents the original code snippet, the corresponding prompt provided to the model, and the reasoning generated by the Claude 4 Sonnet. The LLM produces an incorrect output due to a misevaluation of Python’s split() function on strings, illustrating a reasoning error where the model fails to accurately capture the intended program semantics. Figure 1 . Outputs generated by the LLM: (a) code snippet, (b) corresponding reasoning, and (c) prompt. To address this gap, we conduct the first empirical study on reasoning runtime behavior inference with reasoning LLMs to systematically uncover and characterize the errors in their reasoning traces. For conducting our analysis, we introduce a new benchmark constructed from two widely used program analysis datasets (i.e., HumanEval+ and LiveCodeBench), comprising 427 diverse code snippets. For every snippet, we experiment with three input categories, i.e., regular inputs that represent typical execution scenarios, edge inputs involving boundary conditions and rare execution paths, and invalid inputs, such as malformed data and type mismatches. A total of 12 input values are selected per snippet, each paired with its ground-truth execution outcome. Using this new dataset, we evaluate four state-of-the-art reasoning LLMs, including DeepSeek-R1 ( DeepSeek-AI and et al. 2025 ) , OpenAI o4-mini ( OpenAI et al. 2024 ) , Gemini 2.5 Flash ( Comanici et al. 2025 ) , and Claude 4 Sonnet ( cla [n. d.] ) to explore their reasoning quality by answering the following research questions. • RQ1 (Performance): How accurately can they infer execution outcomes across varying types of inputs? • RQ2 (Failure Location): Which statements or code locations most frequently trigger errors in the LLMs’ reasoning process during code inference? • RQ3 (Failure Pattern): What are the common reasoning error patterns exhibited by reasoning LLMs during execution outcome inference? Our empirical study shows that the evaluated reasoning LLMs (i.e., DeepSeek-R1, OpenAI o4-mini, Gemini 2.5 Flash, and Claude 4) achieve high accuracies ranging from 85% to 98% across all three input types. We further analyze the reasoning errors produced by LLMs on code inference tasks, and we developed a structured taxonomy to categorize these errors. The taxonomy comprises nine high-level categories: Computation Errors , Indexing Errors , Control Flow Errors , Skip Statements , Misreporting Final Output , Input Misread , Misevaluation of Native API , Hallucination , and Lack of Verification/Logic Following . This taxonomy provides a systematic framework for evaluating and understanding the limitations of LLMs in code inference. To address reasoning errors in LLMs, we propose a tool-augmented reasoning approach that supplies reliable intermediate signals, reduces contextual noise, and