Abstract
Dynamic program slicing is a powerful debugging tool that isolates the exact code paths leading to a bug, but it traditionally incurs massive performance overhead, making it unusable in production. This paper introduces "statistical program slicing," a hybrid approach that combines hardware-assisted control flow tracing, cooperative memory sampling, and static analysis to reconstruct failure paths. Our prototype, WOK, recovers 94% of the statements found in a perfect dynamic slice with only a 5% runtime overhead, making it highly practical for analyzing deployed software.
Introduction
When software crashes in production, developers often struggle to reproduce the bug offline because they lack the exact user inputs or environment state. Program slicing is a classic debugging technique that helps by answering: "Which instructions directly or indirectly affected this crashing statement?"
There are two main types of slicing, but both have fatal flaws for production use:
- Static Slicing: Analyzes the source code to find all possible dependencies. It is safe but wildly imprecise, often returning massive chunks of the codebase (too many false positives).
- Dynamic Slicing: Tracks the exact execution of a specific run. It is highly precise but requires heavy instrumentation, causing massive slowdowns that are unacceptable in production environments.
The authors tackle the tension between the need for precise dynamic slicing and the strict performance budgets of production environments. They aim to get the accuracy of dynamic slicing at the cost of lightweight monitoring.
Methodology
The authors built a prototype called WOK that operates in a client-server model, splitting the work between lightweight, always-on client monitoring and offline server analysis.
Key techniques include:
- Hardware-Assisted Control Flow Tracing: WOK uses Intel Processor Trace (PT), a hardware extension that records branch executions with near-zero overhead, to capture the exact control flow of the crashing run.
- Pointer Poisoning (Data Flow Tracking): Because Intel PT doesn't track memory accesses, WOK intercepts heap allocations and "poisons" pointers by altering their high-order bits. When the CPU tries to access this uncanonical address, it triggers a hardware fault. WOK catches the fault, records the memory access, fixes the pointer, and resumes execution.
- Cooperative Sampling: To keep the overhead of hardware faults low, WOK only poisons a tiny fraction of pointers per run. It relies on a "cooperative" environment (like a datacenter) to crowdsource these sampled memory accesses across thousands of different runs, eventually building a complete picture of the program's data dependencies.
- Execution-Driven Static Analysis: To catch dependencies missed by sampling (like stack variables), WOK runs a static alias analysis restricted only to the code paths proven to have executed by the Intel PT trace.
Evaluation and Results
The authors evaluated WOK on 21 real-world, reproducible failures from 6 widely deployed open-source C/C++ applications: Clang, SQLite, Python, Cppcheck, Curl, and Gzip. To simulate a cooperative production environment, they tracked over 3.8 million executions using a mix of test suites and application-specific inputs.
Key Results
- High Accuracy: WOK successfully recovered 94% of the program statements found in a perfect dynamic slice. Furthermore, it recovered 92% of the critical statements directly linking the root cause to the crash symptom.
- Production-Ready Overhead: By tuning the sampling rate to 1 in 100,000 pointers ($p=10^{-5}$), WOK achieved a mere 5% runtime overhead (1.05x slowdown), well within acceptable limits for production deployment.
- Manageable Slice Sizes: The resulting "statistical slices" are a massive 21x smaller than traditional static slices. The authors argue this is an excellent trade-off for a 5% overhead.
Conclusion
Statistical program slicing demonstrates that data flow can be effectively crowdsourced and that hardware features like Intel PT can be repurposed for advanced debugging. While current limitations include imprecise stack tracking and a requirement for fail-stop bugs, WOK provides a scalable foundation for automated root-cause diagnosis in production environments.
Summary updated