CodeSense: a Real-World Benchmark and Dataset for Code Semantic Reasoning

Monoshi Kumar Roy, Simin Chen, Benjamin Steenhoek, Jinjun Peng, Gail E. Kaiser, Baishakhi Ray, Wei Le · DOI

Introduction

While Large Language Models (LLMs) have demonstrated remarkable proficiency in generating syntactically correct code, a critical question remains: do they truly understand the execution logic of the programs they write? Current benchmarks often rely on synthetic puzzles or isolated competitive programming tasks, which may allow models to succeed through "syntactic pattern matching" rather than genuine semantic reasoning.

Researchers have introduced CodeSense, a benchmark designed to evaluate "codesense"—the execution-oriented understanding required for real-world software engineering. This includes reasoning about API side effects, pointer aliasing, and loop dynamics in complex, multi-file project environments.

Methodology

The CodeSense framework utilizes a sophisticated pipeline to extract ground-truth reasoning steps from actual software projects.

The CodeSense Pipeline: Data Curation and Benchmark Creation
  1. Data Collection: 744 real-world projects were gathered across Python, C, and Java.
  2. Execution Tracing: The code was executed using professional debuggers (Pysnooper, GDB, and JDB) to record the exact state of every variable at every line.
  3. Task Formulation: These traces were converted into four reasoning tasks: block-level output prediction, statement-level result prediction, code property reasoning (e.g., pointer aliasing), and value approximation.

Dataset Composition

The resulting dataset consists of 4,495 curated samples derived from 544 Python projects (PyPIbugs), 100 C projects (OSS-Fuzz), and 100 Java projects (SF110). Unlike previous benchmarks, CodeSense includes complex dependencies and third-party API calls, reflecting the realistic challenges of modern software development.

Key Insights and Experimental Results

The study evaluated 14 state-of-the-art LLMs, including the Claude 3.5, GPT-4o, and DeepSeek R1 families. Several critical findings emerged:

  • The "Three-Line" Wall: Model performance degrades sharply as the number of execution steps increases. Even top-tier models like Claude 3.5 achieved only 20% accuracy on 3-statement Python blocks and less than 10% on C.
  • API and Arithmetic Blind Spots: Models struggle significantly with reasoning about third-party API calls and low-level arithmetic, particularly in C. As shown in the performance breakdown, accuracy for API calls remains consistently low across all model families.
LLM Accuracy across different code semantic categories in C and Python
  • Pattern Matching vs. Reasoning: Models often rely on natural language cues (e.g., variable names) rather than logical simulation. When these cues are obscured, performance drops, suggesting a lack of robust internal execution models.
  • Reverse Difficulty: Models are significantly worse at "input prediction" (inferring inputs from a given output) than forward output prediction, highlighting a fundamental gap in the reasoning required for debugging and test generation.

Conclusion

CodeSense reveals a startling performance gap in the semantic reasoning capabilities of current LLMs. While models like Claude 3.5 Sonnet lead the field, they still struggle with the fine-grained execution logic of real-world code. Future work will focus on expanding the benchmark to lower-level languages like Rust and using the CodeSense tracing framework to generate high-quality "chain-of-execution" data to improve model training.

Paper Citation: Roy, M. K., et al. (2025). CodeSense: A Real-World Benchmark and Dataset for Code Semantic Reasoning. https://codesense-bench.github.io/

Summary updated

BibTeX
@inproceedings{roy2026codesense,
  author = {Monoshi Kumar Roy and Simin Chen and Benjamin Steenhoek and Jinjun Peng and Gail E. Kaiser and Baishakhi Ray and Wei Le},
  title = {{CodeSense: a Real-World Benchmark and Dataset for Code Semantic Reasoning}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=ehXVDJm0PS},
}
Figure