Parametric Shape Analysis via 3-Valued Logic
Chenguang Sun sun47@purdue.edu
Parametric Shape Analysis via 3-Valued Logic Chenguang Sun - - PowerPoint PPT Presentation
Parametric Shape Analysis via 3-Valued Logic Chenguang Sun sun47@purdue.edu Previously on Points-to Analysis Our method computes the points-to relationships between stack locations (Page 242) In the case of stack-based
Chenguang Sun sun47@purdue.edu
“Our method computes the points-to relationships between
stack locations” (Page 242)
“In the case of stack-based aliases a name exists for each
stack location of interest.” (Page 243)
“There are no natural names for each location (in heap)”
(Page 243)
“We use a single location called heap in our abstract stack
for the points-to analysis.” (Page 254)
“The stack and heap problems can and should
A “store” is the memory state that arise at a
In the graph
x: Variable n: Field n of a node ui: Node
u3
n n u1 u2
Representing Concrete Stores via First Order Logic
Predicates
“pointed-to-by-variable” (Unary) Pointers from stack into the heap Example: x, y, t, e “pointer-component-points-to” (Binary) Pointer-valued fields of data
structures
Example: n
u3
n n u1 u2
Representing Concrete Stores via First Order Logic
Logical structure S=<US, ιS>
US: Universe of individuals
In this example, individuals are nodes Example: u1, u2, u3
ιS: arity-k Predicates → (Universek → {0, 1})
Example:
u1 1 u2 u3
u1 u2 u3 u1 1 u2 1 u3 u3
n n u1 u2
There are infinite structures. We need a way to abstract.
We consider unary
predicates only. Since
x(u2) = x(u3) = x(u4) y(u2) = y(u3) = y(u4) t(u2) = t(u3) = t(u4) e(u2) = e(u3) = e(u4) u2, u3, u4 can be abstracted
as one summary node u234
Merge u2 u3 u4 Merge u2 u3 u4
One more logical literal ½
0 and 1 are definite values; ½ means “unknown” which is a indefinite value.
l1 ⊑ l2 denotes that l1 has more definite
⊔ denotes least-upper-bound with
⊔{0, 1} = ½
Merge u2 u3 u4
An additional unary predicate, called sm
sm(concrete node) = 0 sm(abstract node) = ½
sm is not an abstraction predicate
Predicate-update formula
For every statement st, the new values of every
predicate p are defined via a predicate-update formula ( ).
φ st p
Structure transformer
When st is not malloc()
US unchanged ιS(p) =
When st is malloc()
US = US ⋃ {unew} ιS(p) =
φ st p φ st p
u3
n n u1 u2 n u4 n
Solution
Add another predicate cn. cn(u) is 1 when there is a
path along n fields from u to u itself, otherwise 0.
Use cn as an additional abstraction predicate.
Predicate-Update Formula for Cn
Predicate-Update Formula for rz,n
Predicate-Update Formula for Instrumentation Predicates
Speed and Accuracy
More instrumentation-predicates; More information (more accurate); More abstraction nodes (slower to process);
New value of y becomes indefinite.
st0: y = y n →
Impossible Structures That Could Be Represented By Sb
φ0 is the predicate update formula for y
Partition the set of structures represented by Sa to three subset
where φ0 evaluates to definite values.
st0: y = y
Constraints from the semantics of the
Constraints from the definitions of the
Sa,o,0 violates the constraint (irreparable):
Sa,o,1 and Sa,o,0 violate the constraints (fixable):
The Focus and Coerce convert a set of three-
The shape-analysis algorithm itself is an
Convergence of The Shape-Analysis Algorithm
S∣≤2∣A∣Aisthe set of abstraction predicates
The number of predicates is fixed. With canonical abstraction, the number of
The number of possible structures is bounded.
Why we need instrument predicates?
To collect the information we are interested in.
Why we need Focus operations?
To maintain the precision of these information by
making sure that the formulas that define the meaning of st evaluate to definite values.
Why we need Coerce operations?
To minimize the set of possible structures by
removing impossible structures.