Most automated vulnerability detectors, code summarizers, and automated repair tools share a common design choice: they analyze source code one function at a time. Treating a function as an isolated unit makes code analysis computationally tractable and fits neatly within the token constraints of modern machine learning models.
However, real-world software is not a collection of isolated islands; it is a complex web of interacting procedures. When an analysis tool confines its vision to intra-procedural boundaries, it develops a critical blind spot known as the inter-procedural context gap.
The Mechanics of the Context Gap
To understand why isolated function analysis fails, consider how data and logic flow through a typical software repository. A security flaw rarely originates, executes, and concludes within the same few lines of code. Instead, it is frequently distributed across multiple layers of function calls.
As Zhen Li 0026 et al. demonstrate in On the Effectiveness of Function-Level Vulnerability Detectors for Inter-Procedural Vulnerabilities, real-world vulnerabilities span an average of nearly three function layers. This distribution creates two fundamental failure modes for intra-procedural models:
- False Negatives (The Hidden Trigger): If a model only evaluates the function where a bug is eventually patched, it misses the external context that triggers the exploit. For instance, an unescaped database query inside a utility function looks perfectly benign unless the model can see that a calling function passes raw, untrusted user input directly into it.
- False Positives (The Hidden Sanitizer): Conversely, a model analyzing a deep utility function might flag a variable as highly dangerous because it lacks validation logic. However, that validation might have already occurred two layers up in the call stack. Without whole-program visibility, the model "cries wolf."
This is not a theoretical limitation. In a real-world user study of Microsoft engineers conducted by K. Sivaraman et al. in Closing the Gap: A User Study on the Real-world Usefulness of AI-powered Vulnerability Detection & Repair in the IDE, over half of the false-positive security alerts generated by AI tools were caused by this exact lack of repository-wide and architectural context. The models frequently flagged safe code as vulnerable because they could not see the sanitization logic residing in external files.
[User Input] ---> Function A()
│
▼ (Unsanitized Data Pass)
Function B() ───► [Sanitization Check?] (Missing Context!)
│
▼
Function C() ---> [Vulnerable Sink Exploded]
Mapping Code Across Procedural Boundaries
To close this gap, recent research focuses on building representations that preserve the relationships between disparate code segments. Instead of treating code as linear text or isolated Abstract Syntax Trees (ASTs), these approaches construct unified, repository-level graphs.
In Repository-Level Graph Representation Learning for Enhanced Security Patch Detection, Xin-Cheng Wen et al. introduce RepoCPG (Repository-Level Code Property Graph). This framework explicitly links data flows and control dependencies across different functions and files. By embedding the entire repository's topology into a unified graph, learning models can trace how a modification in one file propagates through the call graph to affect distant modules.
A similar intuition drives the tracking of memory-related bugs. In MVD, Sicong Cao et al. leverage a Flow-Sensitive Graph Neural Network (FS-GNN) to capture memory allocations that happen in one scope and their subsequent misuses (such as a use-after-free or double-free) that manifest in an entirely different function. By explicitly mapping the cross-function lifecycle of variables, the model successfully captures bugs that isolated function analysis inherently misses.
The Cross-File Blindness
The problem compounds when dependencies cross not just function boundaries, but translation units or file boundaries entirely. For example, a developer might modify a global constant or an object definition in a header file, inadvertently breaking the logic of a dependent source file located in a completely different directory.
Traditional syntactic tracing tools struggle deeply with this scenario. In an empirical study on the Linux kernel, Yunbo Lyu evaluated standard bug-linking algorithms in Evaluating SZZ Implementations: An Empirical Study on the Linux Kernel. The findings revealed that a substantial portion of tracking failures stem from "cross-file blindness"—the algorithms fail because the bug-inducing change and the eventual fix occur in entirely separate files, leaving no local syntactic trace for line-based version control tools to connect.
To bridge this deep local inspection with broad architectural visibility, frameworks are shifting toward staged architectures. As explored by Bhargava Shastry et al. in Towards Vulnerability Discovery Using Staged Program Analysis, systems can combine a fast, local path-sensitive analysis stage with a demand-driven global call-chain tracing stage. This hybrid approach ensures that the detector only pays the computational cost of global tracking when a local analysis flags a potential cross-file dependency, such as an uninitialized memory read or type confusion.
Ultimately, whether the goal is to detect a silent security patch, summarize an API's usage, or automatically repair a compilation error, moving past intra-procedural limitations requires treating a codebase not as a sequence of independent blocks, but as a continuous, interconnected network of execution paths.