Static and Dynamic Analysis: Synergy and Duality: Michael Ernst
Static and Dynamic Analysis: Synergy and Duality: Michael Ernst
analysis:
synergy and duality
Michael Ernst
CSE 503, Winter 2010
Lecture 1
Goals
Theme:
Static and dynamic analyses are more similar than
many people believe
One persons view of their relationship
Goals:
Encourage blending of the techniques and
communities
Start productive discussions
Michael Ernst, page 2
Outline
Review of static and dynamic analysis
Synergy: combining static and dynamic analysis
Aggregation
Analogies
Hybrids
Static analysis
Examples: compiler optimizations, program
verifiers
Examine program text (no execution)
Build a model of program state
An abstraction of the run-time state
Abstract interpretation
Typically implemented via dataflow analysis
Each program statements transfer function
indicates how it transforms state
Example: What is the transfer function for
y = x++;
Selecting an abstract
domain
x = { 3, 5, 7 }; y = { 9, 11, 13 }
x is odd; y is odd
y = x++;
x is even; y is odd
x is prime; y is prime
y = x++;
y = x++;
x = { 4, 6, 8 }; y = { 3, 5, 7 }
x=3, y=11, x=5, y=9, x=7, y=13
y = x++;
x=4, y=3, x=6, y=5, x=8, y=7
Research challenge:
Choose good abstractions
The abstraction determines the expense (in
time and space)
The abstraction determines the accuracy
(what information is lost)
Less accurate results are poor for applications
that require precision
Cannot conclude all true properties in the
grammar
Michael Ernst, page 7
Dynamic analysis
Examples: profiling, testing
Execute program (over some inputs)
The compiler provides the semantics
Observe executions
Requires instrumentation infrastructure
Research challenge:
What to measure?
Coverage or frequency
Statements, branches, paths, procedure calls, types,
method dispatch
Values computed
Parameters, array indices
Research challenge:
Choose good tests
The test suite determines the expense (in time and
space)
The test suite determines the accuracy (what
executions are never seen)
Less accurate results are poor for applications that
require correctness
Many domains do not require correctness!
Static
analysis
Dynamic
analysis
Abstract domain
Concrete execution
slow if precise
slow if exhaustive
Conservative
Precise
due to abstraction
no approximation
Sound
Unsound
due to conservatism
does not generalize
Outline
1. Aggregation:
Pre- or post-processing
Use output of one analysis as input to another
Dynamic then static
Profile-directed compilation: unroll loops, inline,
reorder dispatch,
Verify properties observed at run time
2. Analogous analyses:
Same problem, different
domain
Memory checking
Goal: find array bound violations, uses of uninit. memory
Purify [Hastings 92]: run-time instrumentation
Tagged memory: 2 bits (allocated, initialized) per byte
Each instruction checks/updates the tags
Identical analyses!
Another example: atomicity checking [Flanagan 2003]
Michael Ernst, page 18
Specifications
Specification checking
Statically: theorem-proving
Dynamically: assert statement
Specification generation
Statically: by hand or abstract interpretation
[Cousot 77]
3. Hybrid analyses:
Blending static and
dynamic
Outline
Review of static and dynamic analysis
Synergy: combining static and dynamic analysis
Aggregation
Analogies
Hybrids
Static
analysis
Dynamic
analysis
Abstract domain
Concrete execution
slow if precise
slow if exhaustive
Conservative
Precise
due to abstraction
no approximation
Sound
Unsound
due to conservatism
does not generalize
A hybrid view of
subsets
Bring together static and dynamic analysis by
unifying their subset descriptions
Find subsets with small descriptions with respect to
both data structures and executions
Find a new, smaller description
Outline
Review of static and dynamic analysis
Synergy: combining static and dynamic analysis
Aggregation
Analogies
Hybrids
Potential pitfalls
Analogies between analyses
What applications tolerate unsoundness/imprecision?
Any more low-hanging fruit?
Most static and dynamic approaches differ
Hybrid analyses
How to measure and trade off precision and soundness
What is partial soundness? What is in between?
Subset characterization
Find the unified characterization of behavior
Michael Ernst, page 33
Conclusion
Static and dynamic analysis share many similarities
Communities should be closer
Discussion