On Sequentializing
On Sequentializing
Abstract. We propose a general framework for compositional underapproximate concurrent program analyses by reduction to sequential
program analysesso-called sequentializations. We notice the existing
sequentializationsbased on bounding the number of execution contexts,
execution rounds, or delays from a deterministic task-schedulerely on
three key features for scalable concurrent program analyses: (i) reduction
to the sequential program model, (ii) compositional reasoning to avoid
expensive task-product constructions, and (iii) parameterized exploration
bounds. To understand how those sequentializations can be unified and
generalized, we define a general framework which preserves their key
features, and in which those sequentializations are particular instances.
We also identify a most general instance which considers more executions,
by composing the rounds of different tasks in any order, restricted only
by the unavoidable program and task-creation causality orders. In fact,
we show this general instance is fundamentally more powerful by identifying an infinite family of state-reachability problems (to states g1 , g2 , . . .)
which can be answered precisely with a fixed exploration bound, whereas
the existing sequentializations require an increasing bound k to reach each
gk . Our framework applies to a general class of shared-memory concurrent
programs, with dynamic task-creation and arbitrary preemption.
Introduction
of the other) are then glued together to form larger computations. Intuitively,
this interface composition builds executions according to a round-robin schedule
of k rounds; a complete execution is formed when each ith final global-state of
the last tasks interface matches the (i + 1)st initial global-state of the firsts.
When there are a fixed number of statically-created tasks, interfaces are simply
composed in task-identifier order. In the more general case, with dynamically
created tasks, interfaces are composed in a depth-first preorder over the ordered
task-creation tree. (Note by viewing the task-identifier order as the task-creation
order, the dynamic case subsumes the static.)
Thus, besides features/constraints (i), (ii), and (iii)which we feel are desirable, and important to maintain for efficiency and scalability of the resulting
program analysesthe existing sequentializations are constrained by: (iv) roundrobin executions (in depth-first order on the ordered task-creation tree). Though
other schedules can be simulated by increasing the (round) bounding parameter
k when the number of tasks is bounded, for a fixed value of k, only k-round
round-robin schedules are explored.
The most general instance of the framework we propose in Section 4 subsumes
and extends the existing round-robin based (i.e., context- and delay-bounded)
sequentializations. As in these previous approaches, we restrict ourselves to
explorations that are (i) sequential, (ii) compositional, and (iii) parameterized,
in order to compute task interfaces over k global-state valuation pairs. However,
for the same analysis budget3 (i.e., the bounding parameter k), the general
instance expresses many more concurrent behaviors, essentially by relaxing the
round-robin execution order, and decoupling each task from any global notion
of rounds. We consider that each tasks interface is constructed by composing
the rounds of tasks it has created in any order that respects program order,
and task-creation causality orderi.e., a task is not allowed to execute before a
subsequent preemption of the task that created it. Thus the simulated concurrent
execution need not follow a round-robin schedule, despite the prescribed task
traversal order; the possible inter-task interleavings are restricted only by the
constraint that at most k sub-task round summaries can be kept at any moment
indeed this constraint is necessary to encode the resulting sequentialization with
a bounded number of additional (finite-domain) program variables.
In fact, the most general instance of our framework is fundamentally more
expressive than the existing sequentializations, since there are infinite sequences
of states (e.g., g1 , g2 , . . .) which can be reached with a fixed exploration bound,
whereas the existing sequentializations require an increasing bound k to reach each
gk . This gain in expressiveness may or may not be accompanied by an analysis
overhead. For enumerative program analysis techniques (e.g., model checking,
systematic testing), one may argue that considering more interleavings will have a
negative impact on scalability. This argument is not so clear, however, for symbolic
techniques (e.g., SMT-based verification, infinite-state fixed-point computations),
which may be able to reduce reasoning over very many interleavings to very
few, in practice [20]. Although many device driver bugs have been discovered
3
within few interleavings [21], reducing the number of interleavings could indeed
cause missed bugs in other settings. Furthermore, our hope is that enlightening
the mechanisms behind sequentialization will lead to the discovery of other
succinctly-encodable instances of compositional sequentialization.
Concurrent Programs
P ::=
H ::=
s ::=
|
|
|
x ::=
var g:T H
proc p (var l:T ) s
s; s | x := e | skip | assume e
if e then s else s | while e do s
call x := p e | return e
post p e | yield
g | l
`0 e(g, `)
w0 = `0 , sp
hg, h`, S[post p e]i w, mi aP g, h`, S[skip]i w, m {w0 }
wm
Yield
Complete
hg, h`, S[return e]i , mi
Dispatch
aP
hg, , mi
w0 = h`, S[skip]i w
hg, h`, S[yield]i w, mi aP g, , m {w0 }
Compositional Semantics
add round
import interface
consume round,
where Bim 0 is obtained by removing hg, g 0 i from the head of a sequence in Bim ,
and hBex , Bim i hg, g 0 i is undefined if hg, g 0 i is not at the head of Bim .
5
Summary create
Summary export
d
c
a
c
f e
b
d
f
(a)
b
c
(b)
Summary
consume
Summary import
(c)
(d)
b
a
c
e
ba
d
f
d
c
b
a
Fig. 3. The summary bag operations. Circles represent global valuations (double circles
equivalences), and are paired together in rounded rectangle round summaries. Interfaces
are drawn as stacked round summaries, and shading is used only to easily identify
summaries. (a) Export a constructed interface, (b) begin a round by finalizing the
current round ha, bi, and guessing a valuation c to begin the next, (c) import sub-task
interface, (d) interleave the first unconsumed round ha, bi of a sub-task, updating the
current global state from a to b. The round-summaries Bex to be exported appear above
the dotted line, and the collection Bim of imported sub-task interfaces appears below.
NextRound
B0 = B hg0 , gi
hg0 , g, h`, S[yield]i w, Bi
cP
SubTask
`0 e(g, `)
g 0 Vals
g , g , h`, S[yield]i w, B
Interleave
B0 = B g, g 0
c
p `0 ; Bex
B0 = B Bex
hg0 , g, h`, S[post p e]i w, Bi cP g0 , g, h`, S[skip]i w, B0
Resume
hg0 , g, h`, S[yield]i w, Bi cP hg0 , g, h`, S[skip]i w, Bi
c0 is initial, and
ci cP ci+1 for 0 i < j.
A compositional execution describes the progression of one task only; progressions of sub-tasks are considered recursively as separate executions to compute
the task-summarization relation ;. We say a configuration c = hg0 , g, w, Bi
(alternatively, the global value g) is reachable in P (from c0 ) when there exists an
execution from c0 to c, without using the NextRound rule.6 The compositional
semantics of P , written {|P |}c , maps initial configurations to reachable global
values, i.e., {|P |}c (c0 ) = g if and only if g is reachable in P from c0 .
Although their definitions are wildly different, the compositional and asynchronous semantics are equivalent. To see that every asynchronous execution h
has a corresponding compositional execution, consider, inductively, how to build
the interface summarizing the projection of h a given tasks sub-task segments.
Consider the task A of Fig. 5 which posts B and C. To simulate the asynchronous
(sub-) execution of Fig. 5a, A builds an interface with two uninterruptible rounds
(see Fig. 5c): the first sequencing segments 1 and 2, and the second sequencing
3, 4, 5, and 6. To build this interface, A must import two-round interfaces from
B and C each; note that each round of B and C may recursively contain many
interleaved segments of sub-tasks.
Theorem 1. The compositional semantics and asynchronous semantics are
identical, i.e., for all programs P we have {|P |}c = {|P |}a .7
The proof to this theorem appears in the full version of this paper [4].
Bounded Semantics
Disallowing use of the NextRound rule in the top-level execution ensures that
unchecked guessed global-state valuations are not considered reachable.
We consider initial configurations hg, h`, si , i and hg, g, h`, si , B i as equal.
An asynchronous
(sub-)
execution
An asynchronous
(sub-)
execution
An asynchronous
(sub-) execution
simulated
by compositional
simulated
by compositional
execution
simulated
by compositional
executionexecution
A A BA B BA
AC A BC C C B B C C
(a)
A
1
(b)
2 3
b a b c b dc
b1 a d
A3
b
C
be 3d
ea
b
c B
e 2
f C 4
B
5
6 C c 4e
2 b
f b
g g c5e h
f6d
g g
g 6g
34
cde
fe
54
e g f
f
h
a1
4
d3
c1
b
f3
e4
1,2
3,4,5,6
b2
5
f h g g
a
d
A A
(c)
c
f
hh
1,2
c
h
1,2
a a 3,4,5,6 c c
d3,4,5,6 h
d
h
g4
6 6
hBex , Bim i Bex , Bim 0 obtains Bim 0 from Bim by merging two nodes n and n0 ,
labelled, resp., by hg1 , g2 i and hg2 , g3 i, such that either
(a) there is no directed path from n to n0 in Bim , or
(b) there is an edge from n to n0 in Bim
(see Fig. 6); in either case the merged node is labelled hg1 , g3 i. Note that when
B B 0 we have |B 0 | = |B| 1. Though we could simulate this merge operation in
the (unbounded) compositional semantics, by eventually consuming consecutively
n and n0 into the exported summary list, the merge operation allows to eagerly
express the interleavingthough disallows any subsequent interleaving between
n and n0 . Merging summaries eagerly fixes a sequence of inter-task execution
segments, trading the freedom for external interleaving (which may have uncovered
additional, potentially buggy, behaviors) for an extra space in the bag.
We define the k-bounded compositional semantics of P, written {|P |}kc , by
restricting the compositional semantics {|P |}c to executions containing only
configurations hg0 , g, w, Bi such that |B| k, and adding the additional transition
Compress
B B0
.
hg0 , g, w, Bi cP hg0 , g, w, B 0 i
9
merge
disconnected
(a)
merge
consecutive
(b)
Fig. 6. The bag simplification operations: (a) merging two disconnected but contiguous
round summaries ha, bi and hb, ci (resulting in (b)), and (b) merging two consecutive
and contiguous summaries ha, ci and hc, di (resulting in the small adjacent bag).
Here the literature has assumed a fixed number of finite-state program variables in
order to ignore the effect of complexity resulting from data. Indeed the reachability
problem is EXPTIME-complete in the number of variables, due to the logarithmic
encoding of states in the corresponding pushdown system.
10
Global-Round Explorations
B
(a)
(b)
Fig. 7. (a) 3 global-round exploration, and (b) 4-delay exploration, for a program in
which task A creates B and E, and task B creates C and D. Each tasks interface (drawn
with dashed-lines) summarizes 3 uninterrupted computations (drawn with squiggly
arrows) of the task and all of its sub-tasks. Bold arrows connect global-state valuations,
and dotted arrows connect local-state valuations. Note that the 3-round exploration
allows each task 2 interruptions, while the 4-delay exploration allows all tasks combined
only 4 interruptions.
task ti (in round j), the k j + 1 summaries exported by ti note ti and its
descendants can only execute after round j of tare combined with the k j + 1
accumulated summaries of ts current sub-tasks.9 Thus when t completes round
k, each round i summarizes round i of t followed by round i of each sub-task of
t, in depth-first order, over the ordered task-creation tree of t.
Theorem 3. The k global-round semantics is subsumed by the k-bounded compositional semantics, i.e., for all programs P we have {|P |}kgr ( {|P |}kc .
In fact, our compositional semantics captures many more behaviors than k
global-round analyses. For example, many behaviors cannot be expressed in k
(global) rounds, though can be expressed by decoupling the rounds of different
tasks. Intuitively, the additional power of our compositional semantics is in
the ability to reuse the given bounded resources locally, ensuring only that the
number of visible resources at any point is bounded. The full version of this
paper [4] illustrates an example demonstrating this added analysis power.
Theorem 4. There exists a program P , k0 N, and a sequence g1 , g2 , . . .
{|P |}kc 0 of global-state valuations such that for all k N, gk
/ {|P |}kgr .
5.1
Context-bounding
Using the extension described at the end of Section 4, this combination does not
require additional bag space.
12
allocated tasks, with at most two context-switches between tasks [23]. Shortly
thereafter, Qadeer and Rehof [22] extended CB to explore an arbitrary bound k
of context-switches.
Later, Lal and Reps [20] proposed a linear round-robin task-exploration
order, and instead of bounding the number of context-switches directly, bounded
the number of rounds in an explored round-robin schedule between n tasks.
(It is easy to see that every k-context bounded execution with an unrestricted
scheduler is also a k-round execution with a round-robin scheduler.) With this
scheduling restriction, it becomes possible to summarize each task is execution
by an interface of k global-state valuation pairs, describing a computation that
is interrupted by tasks (i + 1), (i + 2), . . . , n, 1, 2, . . . , (i 1), k 1 times. In fact,
this schedule is just a special case of the k global-round exploration, restricted
to programs with a fixed number of statically-created tasks. La Torre et al. [17]s
subsequent extension of this k-round round-robin exploration to programs with
a parameterized amount of statically-created tasks is also a special case of k
global-round exploration, restricted to programs with an arbitrary number of
statically-created tasks.
To formalize this connection, let a static-task program be an asynchronous
program P which does not contain post statements, and an initial configuration
hg, h`, si , i is (resp., parameterized) static-task initial when s is of the form
post p1 (); ...; post pn ()
Delay-bounding
13
Related Work
The technique of reducing a concurrent program behaviors to sequential program behaviors has garnered much attention in recent years. Based on the
notion of context-bounding [23, 22, 21], Lal and Reps [20] showed how to encode the bounded-round round-robin schedules of a concurrent program with
statically-allocated tasks as a sequential program. La Torre et al. [15] gave a more
efficient encodingin the sense that unreachable global-state valuations are never
exploredand later extended the approach to programs with an unbounded
number of statically-allocated tasks [17]. Emmi et al. [8] have recently extended
the basic insight of round-based scheduling to sequentialize programs with an
14
Conclusion
We have proposed a framework for parameterized and compositional concurrent program analysis based on reduction to sequential program analysis. Our
framework applies to a general class of shared-memory concurrent programs,
with arbitrary preemption and dynamic task-creation, and strictly captures the
known (round-based) sequentializations. It is our hope that this understanding will lead to further advances in sequential reductions, e.g., by enlightening
efficiently-encodable instances of the general framework.
Though we have unified the existing sequentializations while maintaining
their desirable qualities (i.e., sequential program model, compositionality, parameterization) by relaxing the global round-robin schedule, we are aware of
one remaining restriction imposed by our framework. Besides the round-robin
restriction imposed by the existing sequentializations, there is an implicit restriction imposed by translating task-creation directly to procedure calls: the
tasks created by a single task are visited in the order they are created. Though
further generalization is possible (e.g., by adding unbounded counters to the
target program), such reductions will likely lead to much more complex analyses.
15
Bibliography
[13] V. Kahlon. Tractable dataflow analysis for concurrent programs via bounded
languages, July 2009. Patent WO/2009/094439.
[14] N. Kidd, S. Jagannathan, and J. Vitek. One stack to run them all: Reducing
concurrent analysis to sequential analysis under priority scheduling. In SPIN
10: Proc. 17th International Workshop on Model Checking Software, volume
6349 of LNCS, pages 245261. Springer, 2010.
[15] S. La Torre, P. Madhusudan, and G. Parlato. Reducing context-bounded
concurrent reachability to sequential reachability. In CAV 09: Proc. 21st
International Conference on Computer Aided Verification, volume 5643 of
LNCS, pages 477492. Springer, 2009.
[16] S. La Torre, P. Madhusudan, and G. Parlato. Analyzing recursive programs
using a fixed-point calculus. In PLDI 09: Proc. ACM SIGPLAN Conference
on Programming Language Design and Implementation, pages 211222. ACM,
2009.
[17] S. La Torre, P. Madhusudan, and G. Parlato. Model-checking parameterized concurrent programs using linear interfaces. In CAV 10: Proc. 22nd
International Conference on Computer Aided Verification, volume 6174 of
LNCS, pages 629644. Springer, 2010.
[18] S. K. Lahiri and S. Qadeer. Back to the future: revisiting precise program
verification using smt solvers. In POPL 08: Proc. 35th ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, pages 171
182. ACM, 2008.
[19] S. K. Lahiri, S. Qadeer, and Z. Rakamaric. Static and precise detection of
concurrency errors in systems code using SMT solvers. In CAV 09: Proc.
21st International Conference on Computer Aided Verification, volume 5643
of LNCS, pages 509524. Springer, 2009.
[20] A. Lal and T. W. Reps. Reducing concurrent analysis under a context bound
to sequential analysis. Formal Methods in System Design, 35(1):7397, 2009.
[21] M. Musuvathi and S. Qadeer. Iterative context bounding for systematic
testing of multithreaded programs. In PLDI 07: Proc. ACM SIGPLAN
Conference on Programming Language Design and Implementation, pages
446455. ACM, 2007.
[22] S. Qadeer and J. Rehof. Context-bounded model checking of concurrent
software. In TACAS 05: Proc. 11th International Conference on Tools and
Algorithms for the Construction and Analysis of Systems, volume 3440 of
LNCS, pages 93107. Springer, 2005.
[23] S. Qadeer and D. Wu. KISS: Keep it simple and sequential. In PLDI 04:
Proc. ACM SIGPLAN Conference on Programming Language Design and
Implementation, pages 1424. ACM, 2004.
[24] T. W. Reps, S. Horwitz, and S. Sagiv. Precise interprocedural dataflow
analysis via graph reachability. In POPL 95: Proc. 22th ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, pages 4961.
ACM, 1995.
[25] T. W. Reps, S. Schwoon, S. Jha, and D. Melski. Weighted pushdown systems
and their application to interprocedural dataflow analysis. Sci. Comput.
Program., 58(1-2):206263, 2005.
17