TL;DR
This paper introduces "staged symbolic execution," a novel approach to make symbolic execution more efficient for testing object-oriented programs. By separating the generation of abstract symbolic tests (based on class invariants) from their application to specific methods, they significantly reduce redundant computations and enable test reuse, leading to substantial performance improvements.
What Problem Does This Paper Address?
Symbolic execution is a powerful technique for systematically finding bugs by exploring program paths using symbolic inputs. However, its effectiveness is often hampered by scalability issues, especially for object-oriented programs with complex data structures. The traditional approach involves running symbolic execution for each method under test, which can lead to redundant computations, particularly when multiple methods share the same pre-conditions or invariants. This paper tackles the challenge of improving the efficiency and effectiveness of symbolic execution for object-oriented programs by addressing the problem of how to systematically enumerate valid inputs for methods that have pre-conditions, such as class invariants.
Methods
The core innovation is staged symbolic execution, which breaks down the process into two stages:
- Stage 1: Generating Abstract Symbolic Inputs: Instead of immediately executing a method with its pre-condition, this stage focuses on symbolically executing the pre-condition (e.g., a
repOkmethod for a class invariant) once. This generates "abstract symbolic tests." These are not concrete inputs but rather symbolic representations of valid object states, often described as object graphs with symbolic components and associated path conditions. The key idea is that these abstract symbolic tests can be generated independently of specific methods and can be reused. - Stage 2: Regenerating Symbolic Execution State and Testing: In this stage, each method under test is symbolically executed using the pre-generated abstract symbolic tests from Stage 1. The abstract symbolic tests are dynamically expanded into concrete tests based on the control flow of the method being tested. This allows for efficient reuse of the invariant-checking work and avoids recomputing it for every method. The authors also introduce a mechanism to "regenerate" the symbolic execution state from these abstract symbolic inputs, enabling the symbolic execution engine to resume exploration from a valid, pre-established state.
Datasets
The paper evaluates its approach using well-studied subject programs that implement complex data structures, including:
- Binary Search Tree
- Sorted Linked List
- Binary Heap
These are not new datasets but standard benchmarks used to evaluate program analysis and testing techniques. The authors also introduce a mutation-based approach to simulate software evolution for regression testing experiments.
Key Insights and Ideas
- Separation of Concerns for Efficiency: The most significant insight is that separating the computation of valid object states (via pre-conditions/invariants) from the actual method testing can drastically reduce redundant work. This is analogous to pre-computing common sub-expressions.
- Abstract Symbolic Tests as Reusable Assets: Abstract symbolic tests are a powerful concept. They are more compact than concrete test suites and can be stored and reused across different methods or even across different versions of the same method (for regression testing).
- Bridging Black-Box and White-Box Testing: The approach combines the benefits of both. Stage 1, focusing on invariants, is akin to black-box testing (generating inputs based on specifications). Stage 2, using symbolic execution on the method, leverages white-box techniques for path exploration.
- Potential for Test Libraries: The reusability of abstract symbolic tests opens the door to creating libraries of these tests for common data structures, further accelerating testing efforts.
Key Results
The experimental evaluation, comparing staged symbolic execution against standard symbolic execution using KLEE, demonstrates significant improvements:
- Stage 2 Savings: The time spent in Stage 2 (actual method testing) is substantially reduced, often by factors of 2x to 20x, when abstract symbolic tests are reused.
- Reduced Test Suite Size: While not explicitly quantified as a "size" reduction in terms of number of tests, the approach implicitly leads to more efficient test suites by avoiding redundant invariant checks.
- Regression Testing Benefits: The staged approach shows considerable time savings when testing mutants of programs, highlighting its effectiveness in regression testing scenarios where pre-conditions often remain unchanged.
- Handling Complex Arguments: The method proves effective for methods with multiple structurally complex arguments, where standard symbolic execution faces significant overhead.
Limitations and Future Work
- Stage 1 Overhead: The initial cost of generating abstract symbolic tests in Stage 1 can still be substantial, especially for very complex invariants. However, this cost is amortized over multiple uses.
- Symbolic Execution Engine Dependency: The implementation relies on an existing symbolic execution engine (KLEE). While the approach is designed to be adaptable, specific modifications might be needed for different engines.
- Future Work: The authors suggest exploring the creation of a library of abstract symbolic tests for common data structures and extending the approach to handle more complex program features. They also envision integrating this with other techniques like concolic execution for even greater efficiency.
Summary updated