Abstract:
A computer implemented testing methodology employing a scenario-driven modeling of specific instances of bug patterns that commonly occur in concurrent programs which encodes these instances in an SMT-based symbolic analysis. Such modeling and encoding advantageously allow the symbolic analysis framework to focus on real bugs, thereby allowing effective utilization of resources. Experimentation determined a number of previously unknown bugs in public benchmarks and advantageously scenario-specific modeling and encoding improves the scalability of symbolic technique and, therefore, improves overall quality of concurrency testing.

Description:
CROSS REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application claims the benefit of U.S. Provisional Patent Application No. 61/429,533 filed Jan. 4, 2011 and is related to United States Patent Application No. 13/316,123 filed Dec. 9, 2011 the contents of which is incorporated by reference as if set forth at length herein. 
     
    
     FIELD OF THE DISCLOSURE 
       [0002]    This disclosure relates generally to the field of computer software and in particular to techniques for determining concurrency errors in computer software programs. 
       BACKGROUND OF THE DISCLOSURE 
       [0003]    The growth of cheap and ubiquitous multi-processor systems and concurrent library support are making concurrent programming very attractive. However, verification of multi-threaded concurrent systems remains a daunting task especially due to complex and unexpected interactions between asynchronous threads. Unfortunately, testing a program for every interleaving on every test input is often practically impossible. 
       SUMMARY OF THE DISCLOSURE 
       [0004]    An advance in the art is made according to an aspect of the present disclosure directed to a scenario-driven modeling of specific instances of bug patterns based upon common programming oversights including mismatched communication, improper resource utilization and non-atomic updates. Advantageously, such modeling according to an aspect of the present disclosure involves efficient encoding of violation conditions in a quantifier-free SMT formula which are then checked by symbolic analysis which significantly improves the likelihood of finding bugs. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWING 
         [0005]    A more complete understanding of the present disclosure may be realized by reference to the accompanying drawings in which: 
           [0006]      FIG. 1  depicts: (a) an exemplary concurrent system P with threads M a ,M b  with local variables a i ,b i  respectively, communicating with shared variables X, Y, Z, L; (b) lattice and a run σ, and (c) CTP σ  as CCFG, according to an aspect of the present disclosure; 
           [0007]      FIG. 2  shows: (a) MATs {m 1 , . . . , m 5 }, and (b)          -transactions, with local/non-local          -interactions according to an aspect of the present disclosure; 
           [0008]      FIG. 3  depicts an overview of scenario-based modeling and checking of bugs according to an aspect of the present disclosure; 
           [0009]      FIG. 4  shows a CTP with M 1  and M 2  threads where each transition is numbered in the order it was executed in the trace. 
           [0010]      FIG. 5  is a schematic showing a mismatched wait/notify condition according to an aspect of the present disclosure; 
           [0011]      FIG. 6  is a schematic showing schedules captured using MAT-analysis according to an aspect of the present disclosure; 
           [0012]      FIG. 7  is shows Algorithm 1 according to an aspect of the present disclosure; 
           [0013]      FIG. 8  depicts Table 1 which is a comparison of time taken (in sec) by Symbolic Analysis according to an aspect of the present disclosure; 
           [0014]      FIG. 9  depicts (a) MATs {m 1 , . . . , m 5 }, and (b) a run of GenMAT according to an aspect of the present disclosure; and 
           [0015]      FIG. 10  is a schematic diagram depicting an exemplary computer system which may be programmed to perform operations according to an aspect of the present disclosure; 
           [0016]      FIG. 11  is a schematic diagram depicting an exemplary operation of the method of the present disclosure operating on a representative computer system; 
           [0017]      FIG. 12  is a flow diagram depicting exemplary steps of a method according to the present disclosure; 
           [0018]      FIG. 13  is a schematic diagram depicting modeling and encoding of a mismatch communication scenario according to an aspect of the present disclosure; 
           [0019]      FIG. 14  is a schematic diagram depicting modeling and encoding of improper resource allocation scenario according to an aspect of the present disclosure; and 
           [0020]      FIG. 15  is a schematic diagram depicting modeling and encoding of a non-atomic update scenario according to an aspect of the present disclosure. 
       
    
    
     DETAILED DESCRIPTION 
       [0021]    The following merely illustrates the principles of the disclosure. It will thus be appreciated that those skilled in the art will be able to devise various arrangements which, although not explicitly described or shown herein, embody the principles of the disclosure and are included within its spirit and scope. 
         [0022]    Furthermore, all examples and conditional language recited herein are principally intended expressly to be only for pedagogical purposes to aid the reader in understanding the principles of the disclosure and the concepts contributed by the inventor(s) to furthering the art, and are to be construed as being without limitation to such specifically recited examples and conditions. 
         [0023]    Moreover, all statements herein reciting principles, aspects, and embodiments of the disclosure, as well as specific examples thereof, are intended to encompass both structural and functional equivalents thereof. Additionally, it is intended that such equivalents include both currently-known equivalents as well as equivalents developed in the future, i.e., any elements developed that perform the same function, regardless of structure. 
         [0024]    Thus, for example, it will be appreciated by those skilled in the art that the diagrams herein represent conceptual views of illustrative structures embodying the principles of the disclosure. Similarly, it will be appreciated that any flow charts, flow diagrams, state transition diagrams, pseudocode, and the like represent various processes which may be substantially represented in computer readable medium and so executed by a computer or processor, whether or not such computer or processor is explicitly shown. 
         [0025]    The functions of the various elements shown in the Figures, including any functional blocks labeled as “processors”, may be provided through the use of dedicated hardware as well as hardware capable of executing software in association with appropriate software. When provided by a processor, the functions may be provided by a single dedicated processor, by a single shared processor, or by a plurality of individual processors, some of which may be shared. Moreover, explicit use of the term “processor” or “controller” should not be construed to refer exclusively to hardware capable of executing software, and may implicitly include, without limitation, digital signal processor (DSP) hardware, network processor, application specific integrated circuit (ASIC), field programmable gate array (FPGA), read-only memory (ROM) for storing software, random access memory (RAM), and non-volatile storage. Other hardware, conventional and/or custom, may also be included. 
         [0026]    Software modules, or simply modules which are implied to be software, may be represented herein as any combination of flowchart elements or other elements indicating performance of process steps and/or textual description. Such modules may be executed by hardware that is expressly or implicitly shown. 
         [0027]    Unless otherwise explicitly specified herein, the drawings are not drawn to scale. 
         [0028]    1. Introduction 
         [0029]    The growth of cheap and ubiquitous multi-processor systems and concurrent library support are making concurrent programming very attractive. However, verification of multi-threaded concurrent systems remains a daunting task especially due to complex and unexpected interactions between asynchronous threads. Unfortunately, testing a program for every interleaving on every test input is often practically impossible. Runtime-based program analysis infer and predict program errors from an observed trace. Compared to static analysis, runtime analysis often result in fewer false alarms. 
         [0030]    Heavy-weight runtime analysis such as dynamic model checking and satisfiability-based symbolic analysis, search for violations in all feasible alternate interleavings of the observed trace and thereby, report a true violation if and only if one exists. 
         [0031]    In dynamic model checking, for a given test input, systematic exploration of a program under all possible thread interleavings is performed. Even though the test input is fixed, explicit enumeration of interleavings can still be quite expensive. Although partial order reduction techniques (POR) reduce the set of necessary interleavings to explore, the reduced set often remains prohibitively large. Some previous work used ad-hoc approaches such as perturbing program execution by injecting artificial delays at every synchronization points, or randomized dynamic analysis to increase the chance of detecting real races. 
         [0032]    In trace-based symbolic analysis, explicit enumeration is avoided via the use of symbolic encoding and decision procedures to search for violations in a concurrent trace program (CTP). A CTP corresponds to data and control slice of the concurrent program (unrolled, if there is a thread local loop), and is constructed from both the observed trace and the program source code. One can view a CTP as a generator for both the original trace and all the other traces corresponding to feasible interleavings of the events in the original trace. 
         [0033]    Previously, we have introduced mutually atomic transaction (MAT)-based POR technique to obtain a set of context-switches that allow all and only the representative interleavings. We now present the details of scenario-driven modeling and checking of concurrency bugs in a MAT-reduced symbolic analysis used in our concurrency testing framework to improve the likelihood of finding real bugs. 
         [0034]    We present detailed modeling steps of specific instances of bug patterns based on common programming errors such as mismatched communication, improper resource utilization and non-atomic updates (of one or more variables). Such modeling corresponds to efficient encoding of violation conditions in a quantifier free SMT formula, which are then checked for satisfiability on out MAT-based symbolic analysis. 
         [0035]    Specifically, we first use MAT analysis to obtain a set of independent transactions and their interactions. We model scenario-specific independent transactions so that a feasible interleaving in the model is a valid bug-triggering interleaving. We use MAT-based symbolic techniques to search for such big-interleavings in all feasible interleavings of observed events. In essence, we utilize the resources effectively by focusing on the most likely causes of unintended program behaviors. 
         [0036]    2. Related Work 
         [0037]    We now survey various SMT/SAT-based symbolic approaches to search for bounded length witness traces to concurrency errors. Based on how satisfiability formula are generated, symbolic approaches can be broadly categorized into two types namely, 1) synchronous (i.e., with scheduler) and 2) asynchronous (i.e., without scheduler) approaches. 
         [0038]    In the synchronous category, a synchronous model of a concurrent program is constructed with a scheduler, and BMC is used to generate satisfiability formula. Such a model is constructed based on interleaving semantics, where at most one thread transition is scheduled to execute at a time. The scheduler is then constrained to allow context-switch between accesses that are conflicting, i.e., accesses whose relative execution order can produce different global system states. Some researchers have employed sound abstraction with bounded number of context switches (i.e., under-approximation), while others have used finite-state model abstractions, combined with proof-guided method to reduce the set of allowed context switches. 
         [0039]    In the asynchronous category, satisfiability formula are generated directly without constructing a synchronous model of concurrent programs, i.e., without using a scheduler. The concurrency constraints that maintain sequentially consistency are included in the formula for a bounded depth analysis. 
         [0040]    In the CSSA-based approaches, read-value constraints are added between each read and write accesses (on a shared variable), combined with happens-before constraints ordering other writes (on the same variable) relative to the pair. 
         [0041]    In the token-based approach, a single-token system of decoupled threads is constructed first, and then token-passing and memory consistency constraints are added between each pair of shared accesses such that all and only sequential consistent schedules are allowed. 
         [0042]    There have been parallel efforts to detect bugs for weaker memory models using axiomatic memory style specifications combined with constraint solvers, where ordering is encoded explicitly between all pairs of relevant events (shared accesses), resulting in a cubic formulation (in the worst case) in the number of shared accesses, like. 
         [0043]    The presented approach is inspired by our token-based approach proposed originally for the entire concurrent program. Instead of explicit token passing constraints, we use transaction sequence constraints to keep the encoding simpler and succinct for trace programs. This in turn makes the presented approach easier to comprehend and implement. Unlike other symbolic approaches, our encoding does not require a priori limit on context-bounding. 
         [0044]    3. Concurrent System 
         [0045]    A multi-threaded concurrent program P comprises a set of threads and a set of shared variables, some of which, such as locks, are used for synchronization. Let M i  (1≦i≦N) denote a thread model represented by a control and data flow graph of the sequential program it executes. Let V i  be a set of local variables in M i  and           be a set of (global) shared variables. Let C i  be a set of control states in M i . Let           be the set of global states of the system, where a state s ∈           is a valuation of all local and global variables. 
         [0046]    A thread transition t is a 4-tuple &lt;c, g, u, c′&gt; that corresponds to a thread M i , where c, c′ ∈ C i  represent the control states of M i , g is an enabling condition (or guard) defined on V i  ∪         , and u is a set of update assignments of the form v:=exp where variable v and variables in expression exp belong to the set V i  ∪         . Let tid(t) denote the corresponding thread of the transition t . We assume each transition t is atomic, i e , uninterruptible. Let pc i  denote a thread program counter of thread M i . For a given transition t=&lt;c, g, u, c′&gt;, and a state s ∈          , if g evaluates to true in s, and pc i =c, we say that t is enabled in s. 
         [0047]    A schedule of the concurrent program P is an interleaving sequence of thread transitions ρ=t 1  . . . t k . An event e occurs when a unique transition t is fired, which we refer to as the generator for that event, and denote it as t=gen(P, e). A run (or concrete execution trace) σ=e 1  . . . e k  of a concurrent program P is an ordered sequence of events, where each event e i  corresponds to firing of a unique transition t i =gen(P,e i ). We illustrate the differences between schedules and runs later in this disclosure. 
         [0048]    Given a run σ=e 1  . . . e k  for a program P we say e i  happens-before e j , denoted as e i             e j  if i&lt;j. Let t=gen(P, e) and t′=gen(P, e′) . We say t           t′ iff e           e′. For some σ, if e           e′ and tid(t)=tid(t′), we say e            po  e′ and t            po  t′, i.e., the events and the transitions are in thread program order. If t           t′ always and tid (t)≠tid(t′), we refer to such a relation as must happen-before (or must-HB, in short), and denote it as t            HB  t′. We observe such must-HB relation during fork/join, and wait/notify. In the sequel, we restrict the use of must-HB relation to inter-thread events/transitions only. 
         [0049]    Dependency Relation (         ): Given a set T of transitions, we say a pair of transitions (t, t′) ∈ T×T is dependent, i.e. (t, t′) ∈           iff one of the following holds (a) t            po  t′, (b) t            HB  t′, (c) (t, t′) is conflicting, i.e., accesses are on the same global variable, and at least one of them is a write access. If (t, t′) ∉          , we say the pair is independent. 
         [0050]    Equivalency Relation (≃): We say two schedules ρ 1 =t 1  . . . t i ·t i+1  . . . t n  and ρ 2 =t 1  . . . t i+1 ·t i  . . . t i , are equivalent if (t i , t i+1 ) ∉          . An equivalent class of schedules can be obtained by iteratively swapping the consecutive independent transitions in a given schedule. A representative schedule refers to one of such an equivalent class. 
         [0051]    A transaction is an uninterrupted sequence of transitions of a particular thread as observed in a system execution. We say a transaction (of a thread) is atomic w.r.t. a schedule, if the corresponding sequence of transitions are executed uninterrupted, i.e., without an interleaving of another thread in-between. For a given set of schedules, if a transaction is atomic w.r.t. all the schedules in the set, we refer to it as an independent transaction, (denoted as          -transaction) w.r.t. the set. 
         [0052]    Mutually Atomic Transactions (MAT): Two transactions tr=t f  . . . t l  and tr′=t′ f  . . . t′ l  corresponding to thread M and M′ are mutually atomic iff except for the last pair i.e., t l , t′ l , all other transition pairs in the corresponding transactions are independent. All the interleavings of these transactions are equivalent to interleaving either tr·tr′ or tr′·tr, and therefore one can avoid interleaving them in-between. Note, tr·tr′≃/ tr′·tr. 
         [0053]    Concurrent Trace Program (CTP): Given a concrete execution trace σ=e 1  . . . e k , a concurrent trace program w.r.t. σ and concurrent program P, denoted as CTP σ , is a partial ordered set (T σ ,            σ ) such that T σ ={t|t=gen(P, e) where e ∈ σ} is the set of generator transitions, and t            σ  t′ iff ∃t, t′ ∈ T σ t            po  t or t            HB  t′. One can view a CTP as a generator for both the original schedule and all the other schedules by interleaving transitions of σ as per            σ . Two CTP σ  and CTP ψ  can be merged to obtain CTP τ =(T τ ,            τ ) where T τ :=T σ  ∪ T ψ  and t            τ  t′ iff t            σ  t′ or t            ψ  t′ holds. A merged CTP can be effectively represented as a CCFG (concurrent control flow graph) with branching structure but no loop. In the sequel, we refer to such a merged CTP as a CTP. 
         [0054]    Sequentially consistency: A schedule is sequentially consistent iff (a) transitions are in total order, (b) transitions of the same thread are in the program order, (c) each shared read access gets the last data written at the same address location in the total order, and (d) synchronization semantics is maintained. In the sequel, we also refer to such a sequentially consistent schedule as a feasible schedule. We extend the definition of sequential consistency and feasibility to a sequence of          -transactions. 
         [0055]    A data race corresponds to a global state where two different threads can access the same shared variable simultaneously, and at least one of them is a write. 
         [0056]    4. Overview 
         [0057]    In this section, we present an overview of our approach with an example to guide the rest of our discussion. Consider a concurrent system P comprising interacting threads M a  and M b  with local variables a i  and b i , respectively, and shared (global) variables X, Y, Z, L. This is shown in  FIG. 1(   a ) where threads are synchronized with Lock/Unlock. Thread M b  is created and destroyed by thread M a  using fork-join primitives. A thread transition (1b, true, b 1 =Y, 2b) (also represented as 
         [0000]    
       
                 
         
             
             
         
       
     
         [0000]    can be viewed as a generator of access event R (Y) corresponding to the read access of the shared variable Y. 
         [0058]      FIG. 1(   b ) depicts a lattice representing the complete interleaving space of the program. Each node in the lattice denotes a global control state, shown as a pair of the thread local control states. An edge denotes a shared event write/read access of global variable, labeled with W(.)/R (.) or Lock(.)/Unlock(.). Note, some interleavings are not feasible due to Lock/Unlock, which we crossed out (×) in the figure. We also labeled all possible context switches with cs. The highlighted interleaving corresponds to a concrete execution (run) σ of program P 
         [0000]      σ= R ( Y ) b ·Lock( L ) a  . . . Unlock( L ) a ·Lock( L ) b    . . . W ( Z ) b   ·W ( Y ) a ·Unlock( L ) b   ·W ( Y ) b  
 
         [0059]    where the suffices a, b denote the corresponding thread accesses. 
         [0060]    The corresponding schedule ρ of the run σ is 
         [0000]    
       
                 
         
             
             
         
       
     
         [0061]    From σ (and ρ), we obtain a slice of the original program called concurrent trace program (CTP). A CTP can be viewed as a generator of concrete traces, where the inter-thread event order specific to the given trace are relaxed.  FIG. 1(   c ) show the CTP, of the corresponding run σ shown as a CCFG. Each node in CCFG denotes a thread control state (and the corresponding thread location), and each edge represents one of the following: thread transition, a possible context switch, and must-HB relation (such as fork/join). For clarity, we do not show edges that correspond to possible context switches (30 in total). Such a CCFG captures all the thread schedules of CTP σ . 
         [0062]    4.1. Mat-Reduced Symbolic Analysis 
         [0063]    The MAT-reduced symbolic analysis is conducted in four phases: In the first phase, for a given CTP, MAT-analysis is used to identify a subset of possible context switches such that all and only representative schedules are permissible. 
         [0064]    In the second phase, a set of          -transactions and a set of their interactions, referred henceforth as          -interactions, are generated using the reduced set of possible context switches. Recall, an          -transaction is atomic with respect to a set of schedules. Each          -interaction is an ordered pair of          -transactions. There are two types of          -interactions: local, i.e., intra-thread and non-local, i.e., inter-thread. An          -interaction (i,j) is local if          -transactions i,j correspond to the same thread, and j follows i immediately in a program order. An          -interaction (i,j) is non-local if          -transactions i and j correspond to different threads, and there is a context switch from the end control state of i to the begin control state of j. 
         [0065]    As shown in  FIG. 2(   b ), the          -transaction sets corresponding to thread M a  and M b  are AT a ={ta 0 , ta 1 , ta 2 , ta 3 } , and AT b ={tb 1 , tb 2 , tb 3 }, respectively. Their local          -interactions are the ordered pairs: (ta 0 , ta 1 ), (ta 1 , ta 2 ), (ta 2 , ta 3 ), (tb 1 , tb 2 ), (tb 2 , tb 3 ), and non-local          -interactions are the ordered pairs: (ta 1 , tb 2 ), (ta 2 , tb 1 ),(ta 2 , tb 2 ), (ta 2 , tb 3 ), (tb 1 , ta 1 ), (tb 2 , ta 1 ), (tb 3 , ta 1 ), (tb 3 , ta 2 ), (ta 0 , tb 1 ), and (tb 2 , ta 3 ) . Note that last two non-local          -interactions arise due to fork/join. 
         [0066]    We then built an independent transaction model (ITM), where each          -transaction is decoupled from the other. We introduce new symbolic variable for each global variable at the beginning of each          -transaction. This independent modeling is needed to symbolically pair          -transactions in some feasible sequence. 
         [0067]    In the third phase, constraints are added to enforce sequential consistency. The sequential consistency requirement imposes certain restriction in the combination of          -interactions. Total order requirement does not permit any cycles in any schedule. For example, a transaction sequence ta 1 ·tb 2 ·ta 1  is not permissible as it has cycle. Program order requirement is violated in a sequence ta 1 ·tb 2 ·tb 3 ·ta 2 ·tb 1 , although it is a total ordered sequence. 
         [0068]    We add transaction sequence constraints to allow only total and program order sequence of          -transactions, based on          -interactions. In addition, we add synchronization constraints to synchronize the global variables between the non-local          -interactions, and synchronize the local variables between the local          -interactions. Further, we add update constraints corresponding to the update assignments in a transition. 
         [0069]    In the fourth phase, we infer and encode potential concurrency error conditions (as described later). The constraints added form a quantifier-free SMT formula, which is given to a SMT solver to check for its satisfiability. The formula is satisfiable iff there exists a sequentially consistent trace that witnesses the error condition. 
         [0070]    4.2. MAT-Based Partial Order Reduction 
         [0071]    For a given CTP, there may be transition pairs with must-HB relation. As an optimization step (discussed later), we separate the fragments of interacting threads at corresponding transitions, so that each fragment, denoted as IF , does not have any transition pair with must-HB relation. MAT-analysis is then conducted on each fragment independently. 
         [0072]    In the given example ( FIG. 1(   c )), the transition (0a, true, fork(M b ),1a) must happen-before the transition (1b, true, b 1 =Y,2b), and similarly, the transition (6b, true, Y=b 1 +b 2 ,Jb) must happen before the transition (Ja,true,Join(M b ),7). These transition pairs partition the CTP in three fragments: IF 1 , IF 2  and IF 3  where IF 1  is between (0a, -) and (1a, 1b), IF 2  is between (1a, 1b) and (Ja,Jb), and IF 3  is between (Ja,Jb) and (8a, -). Note, IF 2  is the only interacting fragment. In the following, we discuss MAT-analysis for IF 2 . 
         [0073]    Consider a pair (ta m     1   , tb m     1   ) , shown as the shaded rectangle m 1  in  FIG. 2(   a ), where ta m     1    ≡ Lock(L) a ·R(Z) a  . . . W(Y) a  and tb m     1    ≡ R(Y) b  are transactions of threads M a  and M b , respectively. For the ease of readability, we use an event to imply the corresponding generator transition. 
         [0074]    Note that from the control state pair (1a,1b), the pair (Ja,2b) can be reached by one of the two representative interleavings ta m     1   ·tb m     1    and tb m     1   ·ta m     1   . Such a transaction pair (ta m     1   ,tb m     1   ) is atomic pair-wise as one avoids interleaving them in-between, and hence, referred as Mutually Atomic Transaction, MAT for short [?]. Note that in a MAT only the last transition pair have shared accesses on the same variable, maybe co-enabled, and at least one of them being write. Other MATs m 2  . . . m 5  are similar. In general, transactions associated with different MATs are not mutually atomic. For example, ta m     1    in m 1  is not mutually atomic with tb m     3    in m 3  , where tb m     3    ≡ Lock(L) b  . . . W(Y) b . 
         [0075]    The basic idea of MAT-based partial order reduction is to restrict context switching only between the two transactions of a MAT. A context switch can only occur from the ending of a transaction to the beginning of the other transaction in the same MAT. Such a restriction reduces the set of necessary thread interleavings. For a given MAT α=(f i  . . . l i ,f j  . . . l j ), we define a set TP(α) of possible context switches as ordered pairs, i.e., TP(α)={(end(l i ),begin(f j )), (end(l j ),begin(f i ))) where begin(t)/end(t) denote the beginning/ending control states of transition t. Note that there are exactly two context switches for any given MAT. 
         [0076]    Let TP denote a set of possible context switches. For a given interacting fragment IF, we say the set TP is adequate iff for every feasible thread schedules of the IF there is an equivalent schedule that can be obtained by choosing context switching only between the pairs in TP. Given a set                               of MATs, we define TP(                             )=U α∈                               T P(α). A set                               is called adequate iff TP(                             ) is adequate. For a given IF, we use the algorithm GenMAT to obtain a set of                               that allows all (i.e., adequate) and only representative (i.e., optimal) thread schedules, with a running cost 0(N 2 ·k 2 ), where N is number of threads, and k is the maximum number of shared accesses in a thread. 
         [0077]    For the running example, a set                                ab ={m 1 , . . . m 5 } of five MATs is generated. Each MAT is shown as a rectangle in  FIG. 2(   a ). The total number of context switches allowed by the set, i.e., TP(                               ab ) is 8.The highlighted interleaving (shown in  FIG. 1(   b )) is equivalent to the representative interleaving tb m     1   ·ta m     1   ·tb m     3   . We show a run of GenMAT on the running example later. 
         [0078]    4.3. MAT Analysis for CTP 
         [0079]    Let                     denote the set of all fragments for a given CTP. For a given IF i  ∈                    , let TP i  denote the set of context switches as obtained by MAT-analysis on IF i . If IF i  does not have interacting threads, then TP i =Ø. Corresponding to each must-HB relation separating IF i  and IF j , denoted as IF i              HB IF j , let (c i , c j ) denote an ordered pair of non-local control states such that c i  must-happen before c j . We obtain a set of context-switches for CTP, denoted as T CTP , as follows: 
         [0000]    
       
         
           
             
               TP 
               CTP 
             
             := 
             
               
                 
                   ⋃ 
                   
                     
                       IF 
                       i 
                     
                     ∈ 
                     
                        
                       ℱ 
                     
                   
                 
                  
                 
                   TP 
                   i 
                 
               
               ⋃ 
               
                 
                   ⋃ 
                   
                     
                       IF 
                       i 
                     
                      
                     
                       ≺ 
                       HB 
                     
                      
                     
                       IF 
                       j 
                     
                   
                 
                  
                 
                   ( 
                   
                     
                       c 
                       i 
                     
                     , 
                     
                       c 
                       j 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0080]    Proposition 1: The set TP CTP  captures all and only representative schedules of CTP. 
         [0081]    Partitioning a CTP into fragments is an optimization step to reduce the set of infeasible context switches due to must-HB relation. We want to ensure that MAT-analysis does not generate such infeasible context switches in the first place. As perthe claim above, such partitioning does not affect the set of schedules captured, although it reduces TP CTP  significantly. For the running example, T CTP  is given by TP(                               ab ) ∪ {(1a,1b)(Jb,Ja)}. 
         [0082]    A control state c is said to be visible if either (c,c′)/(c′,c) ∈ TP CTP , i.e., either there is a context switch from/to c, respectively; otherwise it is invisible. 
         [0083]    Given TP CTP , we obtain a set of transactions of a thread M i , denoted as AT i , by splitting the sequence of program ordered transitions of M i  into transactions only at the visible control states, such that a context switching can occur either to the beginning or from the end of such transactions. We define          -ATand          -ATPas follows: 
         [0000]    
       
         
           
             
               - 
               AT 
             
             := 
             
               
                 
                   ⋃ 
                   
                     i 
                     = 
                     1 
                   
                 
                 N 
               
                
               
                 AT 
                 i 
               
             
           
         
       
       
         
           
             
               - 
               ATP 
             
             := 
             
               { 
               
                 
                   
                     ( 
                     
                       a 
                       , 
                       b 
                     
                     ) 
                   
                   | 
                   a 
                 
                 , 
                 
                   b 
                   ∈ 
                   AT 
                 
                 , 
                 
                   
                     ( 
                     
                       
                         end 
                         a 
                       
                       , 
                       
                         begin 
                         b 
                       
                     
                     ) 
                   
                   ∈ 
                   
                     TP 
                     CTP 
                   
                 
               
               } 
             
           
         
       
     
         [0084]    where begin a /end a  are the begin/end control state of transaction a, respectively. 
         [0085]    Proposition 2.          -ATPis a set of          -interactions that captures all and only representative schedules of CTP, and          is a set of          -transactions. 
         [0086]    For the running example, the sets AT a  and AT b  are: AT a ={ta 0 =0a . . . 1a, ta 1 =1a . . . 5a, ta 2 =5a·Ja,ta 3 =Ja . . . 8a} and AT b ={tb 1 =1b·2b, tb 2 =2b . . . 6b, tb 3 =6b·Jb}, as shown in  FIG. 2(   b ). We also number each          -transaction as shown in the boxes for our later references. For the interacting thread fragment i.e., IF 2 , we show them as outlines of the lattice in  FIG. 2(   a ). The local and non-local          -interactions corresponding to TP CTP  are shown in the  FIG. 2(   b ). 
         [0087]    Given a set of          -transactions and a set of          -interactions, we add concurrency constraints, denoted as Ω CC , that captures all and only sequential consistent sequence of          -transactions. 
         [0088]    4.4. Scenario-Based Modeling and Checking of Concurrency Bugs 
         [0089]    Our scenario-based modeling and checking of concurrency bugs are illustrated in  FIG. 3 . The main steps are shown therein and are described in the following. 
         [0090]    With reference now to that  FIG. 3 , Given an observed concurrent event trace, corresponding to an execution of a concurrent program, we use the trace information to build an initial concurrent trace program. On the CTP, we carry out MAT analysis to obtain a set of independent transactions and their interactions. 
         [0091]    We identify specific scenarios of bug patterns that correspond to program errors commonly cited in bug reports. 
         [0092]    For a bug-pattern marked mismatch communication, we generate specific instances corresponding to mismatch wait/notify, send/receive synchronization pairs. 
         [0093]    For a bug-pattern marked improper resource utilization, we generate specific instances corresponding to shared heap memory access errors such as invalid pointer access, invalid deallocation, and uninitialized reads. 
         [0094]    For a bug-pattern marked non-atomic update, we generate specific instances based on inferring atomic region based on code layout and correlation of the shared variables. 
         [0095]    For each of the specific scenarios of bug-patterns, we model transaction interactions corresponding to the instance of a bug-pattern. We encode violation condition corresponding to each bug instance into a quantifier free SMT formula. 
         [0096]    We perform MAT-based symbolic analysis using the encoded violation condition as property constraints to search for a feasible interleaving. Presence of such an interleaving represents a bug-triggering interleaving, while its absence represents that the instance of the bug-pattern cannot be violated in any interleaving of the observed events. 
         [0097]    With these principles in place, we may now discuss scenario-based modeling of bugs and corresponding encoding in MAT-based symbolic framework. Basic encoding of assertion and order violations are shown later. 
         [0098]    Given violation constraints, denoted as Ω V , we combine them with Ω CC , and use SMT solver to find a witness trace on the Ω. 
         [0000]      Ω:=Ω CC           Ω V    (1)
 
         [0099]    5. Improper Resource Utilization 
         [0100]    Memory access errors specific to concurrent programs are caused by interleavings overlooked by the programmers. These errors typically are: NULL-pointer accesses, dangling pointer access, buffer overflows, uninitialized read, double and misaligned deallocation. These errors lead to either system crash and/or wrong output results. 
         [0101]    We focus only on shared heap memory accesses that are dynamically allocated and deallocated. We consider three standard C primitives for allocation/deallocation of memory blocks: malloc, realloc and free. All other allocation and deallocation APIs specific to a language can be considered as wrapper procedure calls on these primitives. 
         [0102]    In the following, we describe specific scenarios in concurrent setting where these errors can manifest. 
         [0103]    NULL-pointer access (NPA): We have a NPA violation ( FIG. 4(   a )) when a transition setting a pointer to NULL, i.e., p=0, happens before a transition (of another thread) accessing pointer p, and no allocated memory block was associated to p in-between. 
         [0104]    Dangling pointer access (DPA): We have a DPA violation ( FIG. 4(   b )) when a transition deallocates memory associated with a pointer, i.e., free(p), happens before a transition (of another thread) accessing pointer p, and no allocation was associated to p in-between. 
         [0105]    Buffer overflow access (BOA): We have a BOA violation ( FIG. 4(   c )) when a transition accessing a memory location happens before all transitions (of another thread) allocating the corresponding memory block. 
         [0106]    Double free (DF): We have a DF violation ( FIG. 4(   d )) when a transition deallocating a memory block happens before a transition (of another thread) deallocating the same memory block without its allocation in-between. 
         [0107]    Misaligned free (MF): We have an MF violation ( FIG. 4(   e )) when a transition—setting a pointer p to an address that is different from the beginning address of any allocated memory block—happens-before a transition invoking free operation on p. 
         [0108]    Un-initialized read (UR): We have a UR violation ( FIG. 4(   f )) when a transition of a thread reading a memory location for the first time happens before all transitions writing to the memory location for the first time. 
         [0109]    We use a mem_map to keep a record of allocated entries (i, m i , t) where i denote a unique instance of memory allocation starting at the address m i  occurring in a transition t. During the run, we do the following recording: 
         [0110]    For p:=malloc(n) , we add (i, m i , t), and record the following atomic assignments in a transition t, 
         [0000]      p:=m i    
         [0000]      M i :=n   (2)
 
         [0111]    where M i  is a new variable introduced to record the size of memory allocated. 
         [0112]    For q:=realloc(p,n), we first find an entry (i, m i , t) ∈ mem_map, s.t., p corresponds to m i  for some i. We need to consider two cases: 
         [0113]    memory location unchanged. We record the following assignments in a transition. 
         [0000]      q:=m i    
         [0000]      M i :=n   (3)
 
         [0114]    memory location changed. We add (j, m j , t′) and record the following atomic assignments in a transition t′. 
         [0000]      M i :=0 
         [0000]      q:=m i    
         [0000]      M. j =n   (4)
 
         [0115]    For free(p), we find an entry (i, m i , t) ∈ mem_map, s.t., p=m i  for some i. We record the following assignment in a transition t′. 
         [0000]      M i :=0 
         [0000]      VF t′ :=vf_cond t′ ( p )   (5)
 
         [0116]    where VF t , is the Boolean flag denoting a valid free operation, and vf_cond t′ (p) is a place holder for an expression computed at the end of the run (discussed in the following). 
         [0117]    For any pointer access such as x:=*p or*p :=x, we record a transition t′ iff ∃(i, m i , t) ∈ mem_map s.t., p=m i +k. 
         [0000]      VM t′ :=vm_cond t′ ( p, k )   (6)
 
         [0118]    where VM t′  is a Boolean flag denoting a valid memory accesses, and vm_cond t′ (p, k) is a place holder for an expression computed at the end of the run. 
         [0119]    After the run, we compute vm_cond t′ (p, k) for each pointer access transition t′ as follows: Let vm_cond t′ (p,k):=(p&gt;0) initially. For each (i, m i , t) ∈mem_map s.t.          (t′            HB  t) and         (t′            po t), let vm_cond t′ (p, k) 
         [0000]      vm_cond t′ ( p, k ):=vm c ond t′ ( p, k )         (( p=m   i   +k )→( M   i   &gt;k ))   (7)
 
         [0120]    Similarly, we compute vf_cond t′ (p) for each transition t′ with a free operation of pointer p as follows: Let vf_cond t′ (p):=false initially. For each (i, m i , t) ∈mem_map, s.t.         (t′            HB  t) and          (t′            po  t), let vf_cond t′ (p) as 
         [0000]      vf_cond t′ ( p ):=vf_cond t′ ( p ) ┤ (( p=m   i )         ( M   i &gt;0))   (8)
 
         [0121]    Proposition 3. For a given CTP, if there is no NPA, BOA, and DPA violation, then for each pointer access transition t, the Boolean flag VM t  remains asserted in all interleaving of a CTP. 
         [0122]    We do not track heap memory that was not allocated dynamically, and therefore, we may miss some of these violations. 
         [0123]    Proposition 4. For a given CTP, there is no DF/MF violation iff the Boolean flag V F t  remains asserted in all interleavings of a CTP for each transition t with free operation. 
         [0124]    Each scenario-specific violations are checked as follows: 
         [0125]    Invalid pointer access (NPA,BOA,DPA): A violation occurs when a access pointer does not point to valid non-zero allocated memory. For each pointer access t, we check if VM t  can be falsified. As per Proposition 8, VM t =false if there is NPA, BOA or DPA violation. 
         [0126]    Invalid free (DF/MF): For each access t, we check if VF t  can be falsified. As per Proposition 8, VF t =false iff there is a DF or MF violation. 
         [0127]    Un-initialized read (UR): Let fr i,j /fw i,j  denote the transition where variable i is a first read/write by a thread j, respectively. The UR violation is encoded as follows: 
         [0000]    
       
         
           
             
               
                 
                   
                     Ω 
                     UR 
                   
                   := 
                   
                     
                       
                          
                         i 
                       
                       
                          
                          
                          
                       
                     
                      
                     
                       
                          
                         j 
                       
                       N 
                     
                      
                     
                       
                         
                            
                           
                             k 
                             ≠ 
                             j 
                           
                         
                         N 
                       
                        
                       
                         
                           Ω 
                           ord 
                         
                          
                         
                           ( 
                           
                             
                               f 
                                
                               
                                   
                               
                                
                               
                                 r 
                                 
                                   i 
                                   , 
                                   j 
                                 
                               
                             
                             , 
                             
                               fw 
                               
                                 i 
                                 , 
                                 k 
                               
                             
                           
                           ) 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   9 
                   ) 
                 
               
             
           
         
       
     
         [0128]    where |         | is the number of shared variables. This is a disjunctive formula and can be solved for each fr i,j  separately. 
         [0129]    6. Mis-Match Communication 
         [0130]    We consider mismatch communication between synchronization pairs such as wait/notify. We consider standard C primitives for communication with a conditional variable S and a mutex lock L cond_wait(L, S)/cond_signal(S) corresponding to wait/notify. The wait is often associated with mutex lock and release. All other related API specific to a language can be considered as wrapper procedure calls on these primitives. 
         [0131]    Mismatch communication occurs when a cond_signal(S) happens before its corresponding cond_wait(S). As a result, signal S is lost, and the thread waiting on S may not wake up or wake up late at the next notification of S. Former scenario can cause an application to stall, and the effect is commonly known as communication deadlock. Latter scenario can cause a performance bug due to delayed synchronization. Clearly, such interleavings are not intended by the programmers. 
         [0132]    We describe specific scenarios in concurrent setting where these errors can manifest. During the run, we do the following recording (shown in  FIG. 5 ): 
         [0133]    For cond_wait(L, S), record the following atomic assignments in a transition t pre , 
         [0000]      L:=0 
         [0000]      S:=0   (10)
 
         [0134]    and record the following atomic assignment in a transition t pst  after successful return from cond_wait. 
         [0000]      assume ( S= 1) 
         [0000]      S:=0 
         [0000]      L:=1   (11)
 
         [0135]    For cond_signal(S), we record the following atomic assignment in a transition t s . 
         [0000]      S:=1   (12)
 
         [0136]    Let (t pre ,t s ,t pst ) denote a triplet of transitions corresponding to each matching wait/notify pair on a conditional variable S as observed in the trace. In other words, the transition t pst  is enabled by i s  that happens before it in the trace. Let W(S) denote a set of pair transitions (t pre , t est ) corresponding to each cond_wait(S). Let N(S) denote a set of transitions t s  corresponding to each successful cond_signal(S). Each (t pre , t pst ) E ∈ W(S) has a matching transition t s  ∈ N(S). Other way, it may not be true as some signal may be lost in the run itself. The mismatch wait/notify MWS violation is encoded as follows: 
         [0000]    
       
         
           
             
               
                 
                   
                     Ω 
                     MWS 
                   
                   := 
                   
                     
                        
                       S 
                     
                      
                     
                        
                       
                         
                           ( 
                           
                             
                               t 
                               pre 
                             
                             , 
                             
                               t 
                               pst 
                             
                           
                           ) 
                         
                         ∈ 
                         
                           W 
                            
                           
                             ( 
                             S 
                             ) 
                           
                         
                       
                     
                      
                     
                       
                          
                         
                           
                             t 
                             s 
                           
                           ∈ 
                           
                             N 
                              
                             
                               ( 
                               S 
                               ) 
                             
                           
                         
                       
                        
                       
                         
                           Ω 
                           ord 
                         
                          
                         
                           ( 
                           
                             
                               t 
                               s 
                             
                             , 
                             
                               t 
                               pre 
                             
                           
                           ) 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   13 
                   ) 
                 
               
             
           
         
       
     
         [0137]    In the above equation, for each pair (t pre , t pst ) ∈ W(S) we can prune out a possible t s  ∈ N(S) if t pst              HB  t s  or t pst              ps  t s  . In other words, we have MWS violation if there is an interleaving where all t s  (of cond_signal(S))—that can happen before t est —occurs before t pre  (of a cond_wait(S)). This is a disjunctive formula and can be solved for each triplet separately. 
         [0138]    7. Atomicity Violations 
         [0139]    When a transaction is “expected” (explicitly or implicitly specified by a programmer) to be executed by a thread in an atomic code block, we refer to as an ε-transaction. We now define the semantic correctness of a schedule (or a run) for a given set of ε-transactions, denoted as ε-AT. A pair of ε-transactions t, t′ is said to be executed in a serial order iff end(t)           begin(t′) or end(t′)           begin(t) in the schedule. A schedule is serial w.r.t. ε-AT if each ε-transaction is executed without interruption by other threads, i.e., in serial order. A schedule ρ is serializable w.r.t. ε-AT iff it is “equivalent” to some serial schedule. 
         [0140]    There are various notions of equivalences such as 2PL, commit-order, conflict, view, and state. We focus on conflict-equivalence which has been found to uncover most of the semantic bugs in concurrent programs. However, our approach can be extended easily to other notions of equivalence. 
         [0141]    Two schedules are conflict equivalent iff they involve the same actions of the same transactions and every pair of conflicting actions is ordered the same way. A schedule S is conflict serializable w.r.t. ε-AT if S is conflict equivalent to some serial schedule. 
         [0142]    Given a schedule, one can build a conflict-graph where each node representing an ε-transaction has an edge to another node iff there is a conflicting transition between them. It has been shown that the conflict-graph is cycle-free iff the schedule is conflict-serializable. 
         [0143]    Given two ε-transactions [R(A) 1 ·W(B) 1 ] and [W(A) 2 ·W(B) 2 ] and a run σ=R(A) 1 ·W(A) 2 ·W(B) 2 ·W(B) 1 , the run σ is not conflict-serializable. 
         [0144]    A set of ε-transactions, i.e., ε-AT is conflict-atomic iff every schedule of ε-AT is conflict-serializable w.r.t to all ε-transactions together. We use this notion of atomicity in the remainder of this disclosure. 
         [0145]    A three-access atomicity violation occurs when a schedule t c             t r            t c′  for a given ε-transaction [t c ·t c ′] can not be serialized as (t c , t r ) and (t r , t c′ ) are conflicting. There have been several tools that are designed to detect single variable atomicity violations. As is known by those skilled in the art, such violation occurs quite frequently. 
         [0146]    In the following, however, multiple-variable accesses are often intended to be atomic. For example, C predicate expressions such as S→T.c !=B→T.c; multiple update assignments such as s→len++; s→buf[s→len]:=b; and shared accesses with-in lock/unlock regions involve multiple-variable accesses. Our observation are also confirmed by the bug reports that show that a significant number of concurrency bugs are due to non-atomic updates of multi-variable shared accesses. 
         [0147]    With this intuition, we device a simple mechanism to infer the atomic boundaries based on code layout to obtain a set of E-transactions. 
         [0148]    Inferring atomic regions: Inspired by previous work, we use the following guidelines to infer atomic regions and obtain ε-transactions: 
         [0149]    there are at least two accesses (same or different variable); 
         [0150]    accesses are within a function; 
         [0151]    accesses are less than some threshold maxD distance; 
         [0152]    there is no happen before transition such as thread creation, wait-notify, thread join in-between; 
         [0153]    there is no sleep delay; and 
         [0154]    lock/unlock accesses appear in matching pairs. 
         [0155]    We now discuss encoding to detect atomicity violation for a given set of ε-transactions in a given CTP using the result of MAT-analysis. 
         [0156]    We use MAT-analysis to obtain a set of          -transactions and their interactions. Let          -AT denote a set of          -transactions i ∈ 1 . . . n (each is numbered uniquely). Let          -ATP denote a set of ordered pairs of          -transactions, where in (i,j) ∈          -ATP denotes a possible context switch from i to j. To ease the presentation, we use the following notations/constants for an          -transaction i ∈         -AT: 
         [0157]    begin i /end i : the begin/end control state of i,respectively ; 
         [0158]    tid i : the thread id of i; 
         [0159]    nc_in i /nc_out i : a set of          -transactions (of same thread) which immediately precede/follow i thread locally; 
         [0160]    C i,j : Boolean flag when true denotes that i context switches to j s.t. tid i ≠tid y  and (i,j) ∈          -ATP; and 
         [0161]    NC i,j : Boolean flag when true denotes i is followed immediately by j s.t. i ∈ nc_in j  (or j ∈ nc_out i ) (i.e., end i =begin j ). 
         [0162]    Given an ε-transaction π we obtain a set of {π 1  . . . π i  . . . π |π| } where π i  is a          -transaction, and |π| is the length of the ε-transaction in terms of number of          -transactions, so that for each transition t ∈ π, ∃1≦i≦|π|. t ∈ π i . Note that if |π|=1, the atomicity of the ε-transaction is guaranteed by the MAT analysis. A necessary condition for the atomicity violation, denoted as NAV is an existence of an non-serial schedule, i.e., 
         [0000]    
       
         
           
             
               
                 
                   NAV 
                   := 
                   
                     
                        
                       
                         π 
                         ∈ 
                         
                           ɛ 
                           - 
                           AT 
                         
                       
                     
                      
                     
                       
                          
                         
                           i 
                           = 
                           1 
                         
                       
                       
                         
                            
                           π 
                            
                         
                         - 
                         1 
                       
                     
                      
                     
                        
                       
                         NC 
                         
                           
                             π 
                             i 
                           
                           , 
                           
                             π 
                             
                               i 
                               + 
                               1 
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   14 
                   ) 
                 
               
             
           
         
       
     
         [0163]    MAT analysis generates a set of          -ATP such that all and only representative schedules are permitted, i.e., each of those schedules are not conflict-equivalent to each other. 
         [0164]    Lemma 1. Every representative schedule allowed by MAT analysis has either consecutive          -transactions (of a thread) that are atomic or there exists another          -transaction (of another thread) that has conflict with either one of the interrupted          -transactions. 
         [0165]    For a given set of ε-AT, Not all representative schedules captured by the set          -AT and          -ATP are serial w.r.t. to a given set ε-AT, as shown in  FIG. 6 . In the figure, R represent the set of representative schedules, S0  ⊂  R denote the set of serial order schedules, and NS0=R\S0 denote the set of non-serial order schedules. A schedule ρ ∈ NS0 may be conflict-equivalent to some serial schedule ρ′∈  R . 
         [0166]    We now illustrate the above using an example. Consider thread traces trace 1 =R(X) 1 ·W(Y) 1 ·┤ 1  and trace 2 =W(Y) i ·W(Y) 2 ·┤ 2 . Assuming, transitions ┤ 1  and ┤ 2  are conflicting. A MAT analysis would allow following 3 three schedules: 
         [0000]      ρ a ≡R(X) 1 ·W(Y) 1 ·┤ 1 ·W(Y) 2 ·W(Z) 2  ┤ 2  
 
         [0000]      ρ b ≡W(Y) 2 ·R(X) 1 ·W(Y) 1 ·┤ 1 ·W(Y) 2 ·W(Z) 2  ┤ 2  
 
         [0000]      ρ c ≡W(Y) 2 ·W(Z) 2 ·┤ 2 ·R(X) 1 ·W(Y) 1 ·┤ 1  
 
         [0167]    Given an ε-AT with only one ε-transaction, [W(Y) 2 ·W(Z) 2 ], we obtain the corresponding          -transactions, i.e., {W(Y) 2 ,W(Z) 2 }. The serial schedules w.r.t. to the ε-AT are ρ a  and ρ c , while the non-serial schedule is ρ b . The NAV condition is therefore satisfied only by ρ b . However, ρ b  is conflict-equivalent to a schedule ρ′ b  (which is not conflict-equivalent to either ρ a  or ρ c ). 
         [0000]      ρ′ b ≡W(Y) 2 ·W(Z) 2 ·R(X) 1 ·W(Y) 1 ·┤ 2 ·┤ 1  
 
         [0168]    In general, a representative schedule need not be a serial schedule with respect to the set ε-AT. However, if each ε-transaction has only single access variable, then NAV can also be the sufficient condition as per the following theorem. 
         [0169]    Theorem 1. If each ε-transaction performs either write-all or read-all access only one shared variable, then NAV condition is both necessary and sufficient condition for atomicity violation. Proof. We show that the sufficient condition holds. Let ρ be a non-serial schedule satisfying NAV condition. As per Lemma 1, for any consecutive          -transactions (of an ε-transaction) that are interrupted in ρ (i.e., satisfying NAV condition), there exists an          -transaction that conflicts with both the          -transaction (which are either both write or both read). Thus, p is not a conflict-serializable trace. 
         [0170]    To handle the general case, we present an iterative procedure FindAtomcityViolation (as shown in Algorithm 1). Given a set of ε-AT, we obtain the necessary violation condition NAV as per Eqn. 14. Let Ω CC  represent the set of concurrency constraints based on MAT analysis (as mentioned in Section 4.2). We use an SMT-solver to check if Ω CC           NAV′ is satisfiable, where NAV′ is initialized to NAV. If the check returns UNSAT, it returns NULL as there is no violation possible. On the other hand, if the check returns SAT with a trace ρ, we use a procedure Is_Serializable to check if ρ can be serialized with respect to the given set it. If the procedure fails to find one, we found a true violation and the trace ρ is returned. Otherwise, we obtain a blocking clause cls using the procedure Blocking_Cls as follows: 
         [0000]    
       
         
           
             
               
                 
                   cls 
                   := 
                   
                     
                        
                       
                         π 
                         ∈ 
                         
                           ɛ 
                           - 
                           AT 
                         
                       
                     
                      
                     
                       
                          
                         
                           i 
                           = 
                           1 
                         
                       
                       
                         
                            
                           π 
                            
                         
                         - 
                         1 
                       
                     
                      
                     
                       NC 
                       
                         
                           π 
                           i 
                         
                         , 
                         
                           π 
                           
                             i 
                             + 
                             1 
                           
                         
                       
                       ′ 
                     
                   
                 
               
               
                 
                   ( 
                   15 
                   ) 
                 
               
             
           
         
       
     
         [0171]    Where 
         [0000]        NC′   i,i+1 :=(ρ( NC   π     i     ,π     i+1   )=true)?           C   π     i     ,j              . . .                        C   k,π     i+1     :NC   π     i     ,π     i+1   ,
 
         [0172]    and C π     i     ,j , . . . , C k,π     i+1    denotes all the intermediate context switches from π i  to π i+1  through          -transactions j . . . k. We add this cls to NAV′ constraints, and continue with the SMT_Check. At every step, we prune the set of non-serial schedules by eliminating serializable traces. 
         [0173]    Note that for a special case as indicated by Theorem 6, we do not require more than one SMT_check procedure call. If there is no violation, SMT_Check returns UNSAT; other wise it returns a trace ρ violating the atomicity. 
         [0174]    8. Experiment 
         [0175]    We have implemented our symbolic analysis in a concurrency testing tool CONTESSA. For our experiments, we use 4 multi-threaded publicly available applications: aget, bzip, pf scan, and axel with 1-6 KLOC. These applications has a configurable parameter to set the number of concurrent threads. 
         [0176]    We obtained corresponding concurrent trace programs (CTP), denoted as&lt;name&gt;-&lt;N&gt;-&lt;V&gt;, where name corresponds to the application, N corresponds to the number of threads, and V denotes the violation type: i.e., A for atomicity violation, O for order violation. For order violations, we infer potential uninitialized reads, and potential mismatch wait/notify signals. Each of these potential violations correspond to a unique shared accesses events in a CTP. Although these shared accesses may correspond to multiple executions of the same source lines, we do not differentiate them here for comparison results. 
         [0177]    We used our symbolic encoding, denoted as quad, to generate quantifier-free SMT formula with the error conditions. We compared it with our implementation of cubic formulation, denoted as cubic. We used SMT solver Yices-1.0.28. Our experiments were conducted on a linux workstation with a 3.4 GHz CPU and 2 GB of RAM, and a time limit of 30 minutes per benchmark. 
         [0178]    We present the comparison results in Table 1 depicted in  FIG. 8 . With reference to that Table 1 of  FIG. 8 , Column 1 lists the benchmarks. The characteristics of the corresponding CTPs are shown in Columns 2-6 as follows: the number of threads (n), the number of local variables (#L), the number of global variables (#G), the number of global accesses (#A), and the number of total transitions (#t), respectively. The results of MAT-analysis are shown in Columns 7-10 as follows: the number of MATs (#M), the number of context-switches (i.e.,          -interactions) (#C), the number of          -transactions (#T), and the time taken (t, in sec). 
         [0179]    The type and number of error conditions to check are shown in the Columns 11-12 respectively. Type O refers to order violation and A refers to atomicity violation condition. The result of quad(cubic) is shown in Columns 13-14 (15-16) as follows: number of satisfiable(S)/unsatisfiable(U)/unknown(?) results, and time taken (in sec). 
         [0180]    In our comparison result, we observe that quad encoding provides a significant boost to the performance of the solver, as compared to cubic encoding. For the latter encoding, we observed frequent time-outs and mem-outs. This shows the efficacy of our encoding. We also obtained some interesting results using our framework. 
         [0181]    In aget, all the reported violations correspond to two distinct atomicity violation in the source code. One correspond to a previously known bug which causes garbled output. The other was not reported before, but can cause garbled output as well. 
         [0182]    In pfscan, the atomicity violation and uninitialized memory reported correspond to a scenario where an unprotected read of a result variable races with its protected update else where. This bug was not reported before, and can give a wrong output result. 
         [0183]    For pfscan and bzip, we found some mismatch wait/notify pairs. Although, the mismatch does not stall the application, it can however affect the performance. We are still investigating those scenario. Similarly, we are investigating the uninitialized read memory and atomicity violation found in the application axel. 
         [0184]    9. A Run of GenMAT 
         [0185]    The GenMAT algorithm on the running example (shown in  FIG. 9 ) proceeds as follows. It starts with the pair (1a, 1b), and identifies two MAT candidates: (1a . . . Ja, 1b·2b) and (1a·2a, 1b . . . 6b) . By giving M b  higher priority over M a , it selects a MAT uniquely from the MAT candidates. 
         [0186]    The choice of M b  over M a  is arbitrary but fixed throughout the MAT computation, which is required for the optimality result. 
         [0187]    After selecting MAT m 1 , it inserts in a queue Q, three control state pairs (1a, 2b), (Ja, 2b), (Ja, 1b) corresponding to the begin and the end pairs of the transactions in m 1 . These correspond to the three corners of the rectangle m 1 . In the next step, it pops out the pair (1a, 2b) ∈ Q, selects MAT m 2  using the same priority rule, and inserts three more pairs (5a, 2b), (5a, 6b), (1a, 6b) in Q. 
         [0188]    Note that MAT (1a . . . 5a, 2b·3b) is ignored as the interleaving 2b·3b·1a . . . 5a is infeasible. Note that if there is no transition from a control state such as Ja, no MAT is generated from (Ja, 2b). The algorithm terminates when all the pairs in the queue (denoted as • in  FIG. 9(   a )) are processed. 
         [0189]    We present the run of GenMAT in  FIG. 9(   b ). The table columns provide each iteration step (#1), the pair p ∈ Q selected, the chosen                                ab , and the new pairs added in Q (shown in bold). 
         [0190]    Note that the order of pair insertion in the queue can be arbitrary, but the same pair is never inserted more than once. For the running example, a set                                ab ={m 1 , . . . m 5 } of five MATs is generated. Each MAT is shown as a rectangle in  FIG. 9(   a ). The total number of context switches allowed by the set, i.e., TP (                               ab ) is 8.The highlighted interleaving (shown in  FIG. 9(   b )) is equivalent to the representative interleaving tb m     1   ·ta m     1   ·tb m     3   . One can verify (the optimality) that this is the only representative schedule (of this equivalence class) permissible by the set TP (                               ab ). 
         [0191]    GenMAT generates a set of MATs that captures all (i.e., adequate) and only (i.e., optimal) representative thread schedules. (For the interacting fragments of the threads). Further, its running cost is 0(N 2 ·k 2 ), where N is number of threads,and k is the maximum number of shared accesses in a thread. 
         [0192]    10. Encoding Violations 
         [0193]    We present the encoding for assertion and order violations. We use the following notations: 
         [0194]    χ c : set of transitions beginning at control state c; 
         [0195]    PC c : Boolean flag when true denotes that the local program counter is at c; 
         [0196]    l c /v c : symbolic value of a local (l)/global (v) variable at control state c; 
         [0197]    v c ?: new symbolic variable corresponding to a global variable v at visible c; 
         [0198]    G t IG t ?: guarded symbolic expression corresponding to g(t) at invisible/visible c, respectively; and 
         [0199]    u t /u t ?: update symbolic expression, a conjunction of (v c′ =exp) for each assignment expression (v:=exp) in u(t) at invisible/visbile c, respectively. 
         [0200]    10.1. Assertion Violation 
         [0201]    An assertion condition is associated with a transition t=(c, g, u, c′) where g is the corresponding condition. A assertion violation av occurs when PC c  is true and g(t) evaluates to false. We encode the assertion violation Ω av  as follows: 
         [0000]      Ω av :=PC c                       (16)
 
         [0000]    where G is G t  if c is invisible; other wise G is G t ?. 
         [0202]    10.2. Order Violation 
         [0203]    Given two transitions t, t′ (of different threads) such that t should happen before t′ in all interleaving, one encodes the order violation condition, i.e., t′           t by constraining the          -transaction sequence where          -transaction with transition t′ occurs before the          -transaction with transition t. Let x(t) denote a set of          -transactions where transition t occurs. We encode the order violation condition, denoted as ord(t′,t), as follows: 
         [0000]    
       
         
           
             
               
                 
                   
                     Ω 
                     
                       ord 
                        
                       
                         ( 
                         
                           
                             t 
                             ′ 
                           
                           , 
                           t 
                         
                         ) 
                       
                     
                   
                   := 
                   
                     
                        
                       
                         
                           i 
                           ∈ 
                           
                             x 
                              
                             
                               ( 
                               
                                 t 
                                 ′ 
                               
                               ) 
                             
                           
                         
                         , 
                         
                           j 
                           ∈ 
                           
                             x 
                              
                             
                               ( 
                               t 
                               ) 
                             
                           
                         
                       
                     
                      
                     
                       
                         E 
                         i 
                       
                        
                       
                         E 
                         j 
                       
                        
                       
                         ( 
                         
                           
                             id 
                             i 
                           
                           &lt; 
                           
                             id 
                             j 
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   17 
                   ) 
                 
               
             
           
         
       
     
         [0204]    Note, in case t, t′ are non-conflicting, we explicitly declare them conflicting to allow MAT analysis to generate corresponding context-switches. 
         [0205]    At this point, while we have discussed and described exemplary embodiments and configurations according to an aspect of the present disclosure, those skilled in the art will appreciate that such systems and methods may be implemented on computer systems such as that shown schematically in  FIG. 10  and that a number of variations to those described are possible and contemplated. 
         [0206]    Accordingly, and as depicted schematically in  FIG. 11 , a computer system such as that shown in  FIG. 10  may be programmed to perform the MAT analysis and scenario-driven modeling of bug instances utilizing scenarios or concurrency bugs according to the present disclosure. As so programmed, a MAT-reduced symbolic analysis identifies concurrency bugs in a concurrent program. 
         [0207]      FIG. 12  is a flow diagram depicting more particularly steps associated with the present invention. With reference to that  FIG. 12 , given an observed concurrent event trace (block  101 ) corresponding to an execution of a concurrent program, the trace information is used to build an initial concurrent trace model (CTM) (block  102 ). A MAT analysis is performed on the CTM (block  103 ) to obtain a set of independent transactions and their interactions (block  104 ). 
         [0208]    Next, we identify specific scenarios of bug patterns (blocks  105 - 107 ) that correspond to program errors commonly cited in bug reports. For bug patterns identified as mismatch communication (block  105 ) we generate specific instances corresponding to mismatched wait/notify, lock/unlock, send/receive synchronication pairs. We also infer implicit synchronization induced by sleep calls. 
         [0209]    For bug patterns identified as improper resource utilization (block  106 ), we generate specific instances corresponding to various shared heap memory access errors. 
         [0210]    For bug patterns identified as non-atomic update (block  107 ), we generate specific instances based on inferring atomic region based on code layout and correlation of shared variables. 
         [0211]    For each specific scenario of bug pattern (blocks  105 - 107 ), we model transaction interactions corresponding to an instance of the bug pattern (block  108 ). Such specific modeling are shown for mismatch communication, improper resource utilization and non-atomic updates in  FIG. 13 ,  FIG. 14  and  FIG. 15 , respectively. 
         [0212]    We encode the modeled violation conditions corresponding to each bug instance into a quantifier-free SMT formula (block  109 ). The encoded formula is provided to a MAT-based symbolic analysis using the encoded violation condition as property constraints to search for a feasible interleaving (block  110 ). The presence of such an interleaving represents a bug-triggering interleaving, while its absence represents that the instance of the bug pattern cannot be violated in any interleaving of the observed events. 
         [0213]    With these principles in place, this disclosure should be viewed as limited only by the scope of the claims that follow.