CN104077144A - Data race detection and evidence generation method based on multithreaded program constraint building - Google Patents

Data race detection and evidence generation method based on multithreaded program constraint building Download PDF

Info

Publication number
CN104077144A
CN104077144A CN201410320943.2A CN201410320943A CN104077144A CN 104077144 A CN104077144 A CN 104077144A CN 201410320943 A CN201410320943 A CN 201410320943A CN 104077144 A CN104077144 A CN 104077144A
Authority
CN
China
Prior art keywords
constraint
thread
event
data contention
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201410320943.2A
Other languages
Chinese (zh)
Other versions
CN104077144B (en
Inventor
刘烃
张晓东
俞乐晨
刘沛
郑庆华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Jiaotong University
Original Assignee
Xian Jiaotong University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Jiaotong University filed Critical Xian Jiaotong University
Priority to CN201410320943.2A priority Critical patent/CN104077144B/en
Publication of CN104077144A publication Critical patent/CN104077144A/en
Application granted granted Critical
Publication of CN104077144B publication Critical patent/CN104077144B/en
Priority to PCT/CN2015/081062 priority patent/WO2016004808A1/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a data race detection and evidence generation method based on multithreaded program constraint building. The data race detection problem is converted into a constraint solving problem by building a constraint expression according to the multithreaded program semanteme, a constraint solver is used for detecting possible data races and program execution paths triggering the data races are generated; the data race detection and evidence generation method comprises the steps of firstly, carrying out the instrumentation of the detected program, executing the program and obtaining an execution path, secondly, converting the execution path into a quantifier-free first-order logic expression covering all feasible thread interleaving according to the multithreaded program execution semanteme, thirdly, building a data race candidate set according to the sequential relationship of statements when a data race happens and generating candidate conditions for races, and finally, traversing the candidate set to determine whether the data race exists, and if so, generating a corresponding evidence sequence. The method is capable of finding out all data races in once operation without misinformation; for each data race, the evidence sequence indicating the trigger process of the data race is generated.

Description

The data contention that constraint builds based on multithread programs detects and evidence generation method
Technical field
The present invention relates to trusted software and software test field, particularly a kind of data contention that constraint builds based on multithread programs detects and evidence generation method.
Background technology
Universal along with processor multinucleation, multithreading has become and in software programming, has improved the indispensable technology of cpu busy percentage.Yet, due to the uncertainty interweaving between thread, in multithread programs implementation, may occur that some behaviors that are difficult to expect cause program to be made mistakes, for example synchronous working is not carried out in critical section and the data contention problem that causes.Data contention is that two different threads are not having synchronous protective situation to access an internal memory simultaneously, and has a write operation at least.Data contention not necessarily causes program error, because some programmer deliberately allows program have data contention to improve the efficiency of operation, but has investigation to show that the data contention of 5-24% can produce bad influence to program.Data contention is difficult to be found, because they often occur in the interleaved sequence of some low probability appearance, in reality, often need to spend a lot of time to go to location, its mistake causing is as " corner error ", even also may not remove them completely when software is issued.Therefore, data contention detection is one of multithread programs field tests research point of greatest concern.
In the past few decades, data contention detects existing large quantity research, designs a lot of outstanding robotization testing tools, is mainly divided into static and dynamic state technology.Static method carrys out all data contentions in deduction program by all paths of Static Detection program, can detect most of data contention; But owing to using a large amount of hypothesis, Static Analysis Method can produce invalid data contention, causes rate of false alarm higher.Dynamic approach by monitoring, once carry out in internal memory and synchronizing information to determine whether to exist data contention, the testing result of degree of precision can be provided; The impact with path but dynamic analysing method is subject to interweaving, often will be by repeatedly carrying out to improve coverage rate.Herein static code analysis is combined with program process monitoring, to improve coverage rate and to eliminate as far as possible wrong report.
Existing dynamic detection technology is mainly divided into three kinds: based on lockset, method based on happens-before and the two combination.1) method based on lockset thread is interweaved insensitive, but there is wrong report situation, i.e. ineffective coping.2) method based on happens-before only detects the data contention on certain specific interleaved sequence, though testing result is reliable, is sensitive to thread and interweaves.3) mixed method combines both advantages, and attempts to reduce shortcoming separately, but also faces as searched out hiding mistake, the high problems such as invalid warning that cause of reporting by mistake of lockset.
Summary of the invention
In order to overcome the shortcoming of above-mentioned prior art, the object of the present invention is to provide a kind of data contention that constraint builds based on multithread programs to detect and evidence generation method, according to the semantic constraint expression formula that builds of multithread programs, data contention test problems is converted into constraint solving problem, adopt constraint solver to detect the data contention that may exist, and generate the program execution path of trigger data competition.
To achieve these goals, the technical solution used in the present invention is:
A kind of data contention that constraint builds based on multithread programs detects and evidence generation method, comprises the steps:
S1) under given input, by what carry out pitching pile, treat that measuring program is with generation pass log file, and identify publicly-owned variable in execution route accessing points so that constraint build;
S2) according to program, carrying out semantic is quantifier-free first order logic expression formula by the transformation that interweaves of state transitions, thread in execution route, builds the multithread programs execution route restricted model F that has contained all possible interleaved sequence;
S3) 2 that data contention may occur on all threads in path are considered as to data contention candidate, collect all candidates and build data contention candidate collection DRCS, according to the definition of data contention, build each candidate's competition occurrence condition ρ simultaneously;
S4) for each candidate, compete occurrence condition ρ, utilize constraint solver checking F ∧ ρ whether to have solution;
S5), if there is solution, represent that this race condition can trigger real data contention; If without solution, represent that this candidate can trigger data not compete;
S6), when there is data contention, export the evidence sequence of this data contention;
S7), for data contention candidate collection DRCS, if traversal finishes, export all results; Otherwise, continue the next competition of traversal candidate;
S8) after checking finishes, all data contentions that output detections arrives and corresponding evidence sequence.
The present invention further improves and is: described step S1), pitching pile work is not carried out in source code or binary aspect, but complete in the aspect of bytecode, specific implementation method is: first multithread programs source code to be measured is converted into intermediary bytes code form, i.e. LLVM bytecode; Then the statement with monitoring function is implanted and treated measuring program; Finally the bytecode of implant monitor code is linked into executable program.
The present invention further improves and is: described step S2), multithread programs execution route restricted model F has contained all possible interleaved sequence of execution route, comprise five kinds of constraints: path expression, memory model constraint, read-write relation constraint, partial order constraint and synchronization semantics constraint, definition is as follows respectively:
1) path expression: describe definition-use chain of thread inside, and control the conversion of thread internal state;
2) memory model constraint: the relation in representation program between statement, variable, the semanteme of employing Ordinal Consistency, Ordinal Consistency regulation CPU carrys out executive routine according to the order of statement in code;
3) read-write relation constraint: definition-use chain of definition cross-thread, the value that regulation shared variable reads, must be from initial value and the nearest value of writing;
4) partial order constraint: create thread and terminate thread action statement between definition thread in the sequential relationship by between operation thread statement;
5) synchronization semantics constraint: the sequential relationship between definition thread between synchro control action statement;
Wherein, definition-use chain to be: each thread sequence is converted into SSA form, and for the execution sequence of each SSA form, removing share and access point is all complete definition-use chain.
The present invention further improves and is: described step S2), the construction method of multithread programs execution route restricted model F comprises following operation:
1) calculating path expression formula, shifts to control thread internal state;
2) calculate memory model constraint, to limit the relation between statement in thread;
3) calculate read-write relation constraint, to set up definition-use chain of cross-thread;
4) calculate synchronization semantics constraint, to define cross-thread synchronized relation;
5) calculate partial order constraint, to describe the semanteme of thread creation and termination;
Finally, in conjunction with above five kinds of constraints, form restricted model F.
The present invention further improves and is: definition execution route event sets wherein k is number of threads, T i={ e 1, e 2..., e nas the execution sequence of thread i, e nrepresent T in event, O (e n) presentation of events e norder, n represents T ievent number:
The computing method of described path expression:
Each thread sequence is converted into SSA form, is similar to the collection of path condition (Path Condition), directly SSA layout sequence is converted into path expression;
The computing method of described memory model constraint:
Adopt sequential consistency model, the order of the complete follow procedure of all operations is carried out, and the event sequence in thread meets constraint:
E wherein iwith e i+1represent two continuous events in same thread, τ represents all thread sequence;
The computing method of described read-write relation constraint:
What make shared variable reads to come from nearest writing, and for same shared variable v, makes R as all event sets that it is carried out to read operation, makes W as all event sets that it is carried out to write operation, provides following formula:
Wherein, e rfor reading event, e wwith e xfor writing event, v rand v wfor event e rwith e woperated variable, the expressed meaning of formula is, if event e rin v rvalue comes from event e win v w, first to meet e rat e wafterwards, i.e. O (e w) < O (e r); Then to meet all write or at e wbefore, or at e rafterwards;
The computing method of described synchronization semantics constraint comprise lock/unlock and wait/signal two generic operations:
1) object of lock/unlock operation is for building the constraint of lock synchronization semantics, in the lock/unlock set L requiring in same mutual exclusion lock, for any two lock/unlock event pair: l i/ u iwith l k/ u k, must meet formula:
Wherein, lock is to l i/ u ioccur in lock to l k/ u kbefore, or occur in thereafter;
2) object of wait/signal operation is to build the constraint of conditional-variable synchronization semantics, satisfy condition: each wait operation must operate by a corresponding signal, and signal is operated to and wakes a wait operation more up, for identical conditions variable cond, make WT as the set of all wait operations on cond, make SG as the set of all signal operations on cond, the condition as on will meeting, must have following formula:
Wherein, e wtfor the arbitrary element in WT, SG wtrepresent e wtthe set of the signal operation that can mate, e sgfor SG wtin arbitrary signal Action Events, utilize variable whether equal 1 and represent e sgwhether with e wtmatch.Subformula represent, for each wait operation e wtmust there is a signal operation to match;
The computing method of described partial order constraint:
First stipulate: if event creates a thread, all events that are created so thread all will be carried out after this event; If event execution thread terminating operation, all events that are terminated so thread all will be before this event; Making C is the event sets of create/fork operation, makes J as the event sets of join operation; Given constraint:
Wherein, e cfor thread creation event, first (e c) be e cthe order of the first event of thread creating; e ifor thread stops event; Last (e j) be e jthe order of the thread end event finishing;
Above five kinds of constraints and formation restricted model F.
The present invention further improves and is: described step S3), the construction method of competition occurrence condition ρ is as follows: if there is paths τ=< τ 1e ie jτ 2>, wherein τ 1prefix, τ 2suffix, event e iwith e jbelong to different threads and all access same internal memory, having at least one to write, data contention has occurred between the two so, and τ regarding e as iwith e jthe evidence sequence of data contention; Event e for the same variable of access iwith ek, e ' iwith e " irepresent respectively e iprevious event and a rear event; Equally, e ' kwith e " krepresent respectively e kprevious event and a rear event, there is data contention and access the condition ρ of same internal memory simultaneously and be in both so:
O(e′ i)<O(e k)<O(e″ i)∧O(e′ k)<O(e i)<O(e″ k)。
The present invention further improves and is: described step S7), for each data contention, can generate evidence sequence, to describe its trigger process.
Compared with prior art, the invention has the beneficial effects as follows:
(1) propose a kind of multithread programs constraint and build model, once executory data contention test problems is converted into constraint solving problem.This model retrains structure according to Program Semantics, and constructed expression formula has comprised all possible interleaved sequence, and then detects all data contentions in execution route.
(2) all data contentions all being produced to an evidence sequence, is the information how to be triggered so that data contention to be provided to user.
(3) to carrying out sequence, carry out ex-post analysis, the huge run-time overhead that does not exist on-the-fly technology to produce.
Accompanying drawing explanation
Fig. 1 is the inventive method overall flow figure.
Fig. 2 is multithread programs path constraint construction method process flow diagram.
Embodiment
Below in conjunction with accompanying drawing and example in detail embodiments of the present invention.
Treat that measuring program is as follows, x and y are shared variable, and thread 0 has created thread 1 and thread 2.
As shown in Figure 1, data contention of the present invention detects and evidence generation method, comprises the steps:
Step S1): monitor code is implanted to tested program, so that the implementation of program is carried out to record.Under given input, carry out example procedure, record path π=[1,2,3,4,5,6,7,8,9,10,11]; Then, identify shared variable accessing points, comprise { 1,5,7,9,10}.
Step S2): according to program, carrying out semantic is quantifier-free first order logic expression formula by the transformation that interweaves of state transitions, thread in execution route, build the restricted model F of execution route π, comprise path expression, memory model constraint, read-write relation constraint, partial order constraint, synchronization semantics constraint.Whole restricted model F has contained all possible interleaved sequence of execution route.Particularly, as shown in Figure 2, according to following steps, generate corresponding logical expression:
S201) first, the share and access point according to identifying, is converted into SSA form by path π, as follows:
initialization : x w 0 = 0 , y w 0 = 0
1 : x w 1 = 0 ;
2:create(1);
3:create(2);
4:lock(m);
5 : x w 2 = a + b ;
6:unlock(m);
7 : y w 1 = y r 1 + 1 ;
8:lock(m);
9 : x w 3 = x r 0 + 1 ;
10 : y w 2 = y r 2 + 1 ;
11:unlock(m);
Wherein, for the subscript of global variable x and y, represent to read (r) or write (w), superscript is distinguished different read or writes, and superscript is 0 to be expressed as initial assignment.
Then, according to the SSA form in path, directly calculate the path expression of path π, following formula:
S202) build memory model constraint, adopt sequential consistency model, the order of regulation all operations follow procedure is carried out.According to formula:
Calculate the memory model constraint of path π, as following formula:
o(e 1)<o(e 2)<o(e 3)∧
o(e 4)<o(e 5)<o(e 6)<o(e 7)∧
o(e 8)<o(e 9)<o(e 10)<o(e 11)
Wherein, o irepresent the arrangement sequence number in i line statement interleaved sequence.
S203) calculate read-write sequence constraint, what make shared variable reads to come from nearest writing.For same shared variable v, make R as all event sets that it is carried out to read operation, make W, as all, it be carried out to the event sets of write operation.Provide following formula:
Wherein, e rfor reading event, e wwith e xfor writing event.The expressed meaning of formula is, if event e rin v rvalue comes from event e win v w, first to meet e rat e wafterwards, i.e. O (e w) < O (e r); Then to meet all write or at e wbefore, or at e rafterwards.
In the π of path, for global variable x, R={e 9, W={e 0, e 1, e 5, e 9, the following formula of its read-write relational expression:
Wherein, to the read-write of variable x, may enumerate, when the 9th row x read to come from the writing of the 1st row x time, should meet: the 1st row is before the 9th row, and the 5th row can not occur between the two writing of x.The situation of y variable is similar to x.
S204) calculate synchronization semantics constraint, comprise lock/unlock and wait/signal two generic operations:
1) while building lock synchronization semantics constraint (lock/unlock operation), in the lock/unlock set L requiring in same mutual exclusion lock, for any two lock/unlock event pair: l i/ u iwith l k/ u k, must meet formula:
Wherein, lock is to l i/ u ioccur in lock to l k/ u kbefore, or occur in thereafter.
2) while building conditional-variable synchronization semantics constraint (wait/signal), satisfy condition: each wait operation must corresponding signal operation, and signal is operated to and wakes a wait more up and operate.For identical conditions variable cond, make WT as the set of all wait operations on cond, make SG as the set of all signal operations on cond.Condition as on will meeting, must have following formula:
Wherein, make e wtfor an element in WT, SG wtrepresent e wtthe set of the signal operation that can mate, WT sgrepresent e sgthe set of the wait operation that can mate.Utilize variable herein whether equal 1 and represent e sgwhether with e wtmatch.Subformula represent, for each wait operation e wtmust there is a signal operation to match.
In the π of path, only have lock m, synchronization semantics constraint formulations is as follows:
o(e 6)<o(e 8)∨o(e 11)<o(e 4)
Wherein, constraint expression formula represent otherwise thread 1 first obtain lock o 6< o 8, or thread 2 first obtains lock o 11< o 4.
S205) calculate partial order constraint, its regulation: if event creates a thread, all events that are created so thread all will be carried out after this event.If event execution thread terminating operation, all events that are terminated so thread all will be before this event.Making C is the event sets of create/fork operation, makes J as the event sets of join operation.Given constraint:
Wherein, e cfor thread creation event, first (e c) be e cthe order of the first event of thread creating; e jfor thread stops event; Last (e j) be e jthe order of the thread end event finishing.
In the π of path, thread creation statement is O 2, O 3, its partial ordering relation retrains following formula:
o(e 2)<o(e 4)∧o(e 3)<o(e 8)
Wherein, constraint representation thread creation statement the 2nd row is carried out before it is created the first event of thread 1.
S206) above five kinds of constraints are carried out with, obtain restricted model F.
Step S3): build data contention candidate collection, and the competition occurrence condition that generates each candidate.Event e for the same variable of access iwith e k, e ' iwith e " irepresent respectively e iprevious event and a rear event; Equally, e ' kwith e " krepresent respectively e kprevious event and a rear event, the condition ρ that data contention (simultaneously accessing same internal memory) occurs for both is so:
O(e′ i)<O(e k)<O(e″ i)∧O(e′ k)<O(e i)<O(e″ k)。
Candidate collection in this example and competition occurrence condition are as follows:
Candidate's occurrence condition
<1,5>?o(e 5)<o(e 2)∧o(e 4)<o(e 1)<o(e 6)
<1,9>?o(e 9)<o(e 2)∧o(e 8)<o(e 1)<o(e 10)
<5,9>?o(e 4)<o(e 9)<o(e 6)∧o(e 8)<o(e 5)<o(e 10)
<7,10>?o(e 6)<o(e 10)∧o(e 9)<o(e 7)<o(e 11)
Data contention is defined as and ought accesses same internal memory by two threads simultaneously, and has a write operation at least.Take the 4th candidate as example explanation, o (e 6) < o (e 10) ∧ o (e 9) < o (e 7) < o (e 11) represent to occur between the 7th row and the 10th row the condition of data contention, wherein o (e 9) < o (e 7) < o (e 11) represent that the 7th row can occur between the last event (the 9th row) and a rear event (the 11st row) of the 10th row; Due to the 7th behavior thread end, therefore only use o (e 6) < o (e 10).This race condition is set up explanation the 7th row and the 10th row can be accessed same variable y simultaneously, occurs data contention.
Step S4 mono-S7): for each candidate, utilize solver to solve F ∧ ρ, whether candidates all in verification msg competition candidate collection DRCS are valid data competitions.Below verify one by one each candidate:
Checking F ∧ o (e 5) < o (e 2) ∧ o (e 4) < o (e 1) < o (e 6), result draws the 1st row and the 5th capable data contention that do not occur;
Checking F ∧ o (e 9) < o (e 2) ∧ o (e 8) < o (e 1) < o (e 10), result draws the 1st row and the 9th capable data contention that do not occur;
Checking F ∧ o (e 4) < o (e 9) < o (e 6) ∧ o (e 8) < o (e 5) < o (e 10), result draws the 5th row and the 9th capable data contention that do not occur;
Checking F ∧ o (e 6) < o (e 10) ∧ o (e 9) < o (e 7) < o (e 11), result draws data contention between the 7th row and the 9th row, and evidence sequence is: 1,2,3,4,5,6,8,9,10,7,11.
After having traveled through DRCS, stop checking work.
Step S8) collect all data contentions and corresponding evidence sequence.

Claims (7)

1. the data contention that constraint builds based on multithread programs detects and evidence generation method, it is characterized in that, comprises the steps:
S1) under given input, by what carry out pitching pile, treat that measuring program is with generation pass log file, and identify publicly-owned variable in execution route accessing points so that constraint build;
S2) according to program, carrying out semantic is quantifier-free first order logic expression formula by the transformation that interweaves of state transitions, thread in execution route, builds the multithread programs execution route restricted model F that has contained all possible interleaved sequence;
S3) 2 that data contention may occur on all threads in path are considered as to data contention candidate, collect all candidates and build data contention candidate collection DRCS, according to the definition of data contention, build each candidate's competition occurrence condition ρ simultaneously;
S4) for each candidate, compete occurrence condition ρ, utilize constraint solver checking F ∧ ρ whether to have solution;
S5), if there is solution, represent that this race condition can trigger real data contention; If without solution, represent that this candidate can trigger data not compete;
S6), when there is data contention, export the evidence sequence of this data contention;
S7), for data contention candidate collection DRCS, if traversal finishes, export all results; Otherwise, continue the next competition of traversal candidate;
S8) after checking finishes, all data contentions that output detections arrives and corresponding evidence sequence.
2. the data contention that constraint builds based on multithread programs according to claim 1 detects and evidence generation method, it is characterized in that, described step S1) in, pitching pile work is not carried out in source code or binary aspect, but complete in the aspect of bytecode, specific implementation method is: first multithread programs source code to be measured is converted into intermediary bytes code form, i.e. LLVM bytecode; Then the statement with monitoring function is implanted and treated measuring program; Finally the bytecode of implant monitor code is linked into executable program.
3. the data contention that constraint builds based on multithread programs according to claim 1 detects and evidence generation method, it is characterized in that, described step S2) in, multithread programs execution route restricted model F has contained all possible interleaved sequence of execution route, comprise five kinds of constraints: path expression, memory model constraint, read-write relation constraint, partial order constraint and synchronization semantics constraint, definition is as follows respectively:
1) path expression: describe definition-use chain of thread inside, and control the conversion of thread internal state;
2) memory model constraint: the relation in representation program between statement, variable, the semanteme of employing Ordinal Consistency, Ordinal Consistency regulation CPU carrys out executive routine according to the order of statement in code;
3) read-write relation constraint: definition-use chain of definition cross-thread, the value that regulation shared variable reads, must be from initial value and the nearest value of writing;
4) partial order constraint: create thread and terminate thread action statement between definition thread in the sequential relationship by between operation thread statement;
5) synchronization semantics constraint: the sequential relationship between definition thread between synchro control action statement;
Wherein, definition-use chain to be: each thread sequence is converted into SSA form, and for the execution sequence of each SSA form, removing share and access point is all complete definition-use chain.
4. the data contention building based on multithread programs constraint according to claim 3 detects and the evidence method of generationing, it is characterized in that described step S2) construction method of middle multithread programs execution route restricted model F comprises following operation:
1) calculating path expression formula, shifts to control thread internal state;
2) calculate memory model constraint, to limit the relation between statement in thread;
3) calculate read-write relation constraint, to set up definition-use chain of cross-thread;
4) calculate synchronization semantics constraint, to define cross-thread synchronized relation;
5) calculate partial order constraint, to describe the semanteme of thread creation and termination;
Finally, in conjunction with above five kinds of constraints, form restricted model F.
5. the data contention that constraint builds based on multithread programs according to claim 4 detects and evidence generation method, it is characterized in that definition execution route event sets wherein k is number of threads, T i={ e 1, e 2..., e nas the execution sequence of thread i, e nrepresent T in event, O (e n) presentation of events e norder, n represents T ievent number:
The computing method of described path expression:
Each thread sequence is converted into SSA form, directly SSA layout sequence is converted into path expression;
The computing method of described memory model constraint:
Adopt sequential consistency model, the order of the complete follow procedure of all operations is carried out, and the event sequence in thread meets constraint:
E wherein iwith e i+1represent two continuous events in same thread, τ represents all thread sequence;
The computing method of described read-write relation constraint:
What make shared variable reads to come from nearest writing, and for same shared variable v, makes R as all event sets that it is carried out to read operation, makes W as all event sets that it is carried out to write operation, provides following formula:
Wherein, e rfor reading event, e wwith e xfor writing event, v rand v wfor event e rwith e woperated variable, the expressed meaning of formula is, if event e rin v rvalue comes from event e win v w, first to meet e rat e wafterwards, i.e. O (e w) < O (e r); Then to meet all write or at e wbefore, or at e rafterwards;
The computing method of described synchronization semantics constraint comprise lock/unlock and wait/signal two generic operations:
1) object of lock/unlock operation is for building the constraint of lock synchronization semantics, in the lock/unlock set L requiring in same mutual exclusion lock, for any two lock/unlock event pair: l i/ u iwith l k/ u k, must meet formula:
Wherein, lock is to l i/ u ioccur in lock to l k/ u kbefore, or occur in thereafter;
2) object of wait/signal operation is to build the constraint of conditional-variable synchronization semantics, satisfy condition: each wait operation must operate by a corresponding signal, and signal is operated to and wakes a wait operation more up, for identical conditions variable cond, make WT as the set of all wait operations on cond, make SG as the set of all signal operations on cond, the condition as on will meeting, must have following formula:
Wherein, e wtfor the arbitrary element in WT, SG wtrepresent e wtthe set of the signal operation that can mate, e sgfor SG wtin arbitrary signal Action Events, utilize variable whether equal 1 and represent e sgwhether with e wtmatch.Subformula represent, for each wait operation e wtmust there is a signal operation to match;
The computing method of described partial order constraint:
First stipulate: if event creates a thread, all events that are created so thread all will be carried out after this event; If event execution thread terminating operation, all events that are terminated so thread all will be before this event; Making C is the event sets of create/fork operation, makes J as the event sets of join operation; Given constraint:
Wherein, e cfor thread creation event, first (e c) be e cthe order of the first event of thread creating; e jfor thread stops event; Last (e j) be e jthe order of the thread end event finishing;
Above five kinds of constraints and formation restricted model F.
6. the data contention that constraint builds based on multithread programs according to claim 1 detects and evidence generation method, it is characterized in that described step S3) in the construction method of competition occurrence condition ρ as follows: if there is paths τ=< τ 1e ie jτ 2>, wherein τ 1prefix, τ 2suffix, event e iwith e jbelong to different threads and all access same internal memory, having at least one to write, data contention has occurred between the two so, and τ regarding e as iwith e jthe evidence sequence of data contention; Event e for the same variable of access iwith e k, e ' iwith e " irepresent respectively e iprevious event and a rear event; Equally, e ' kwith e " krepresent respectively e kprevious event and a rear event, there is data contention and access the condition ρ of same internal memory simultaneously and be in both so:
O(e′ i)<O(e k)<O(e″ i)∧O(e′ k)<O(e i)<O(e″ k)。
7. the data contention building based on multithread programs constraint according to claim 1 detects and evidence generation method, it is characterized in that described step S7) in for each data contention, can generate evidence sequence, to describe its trigger process.
CN201410320943.2A 2014-07-07 2014-07-07 Data race detection and evidence generation method based on multithreaded program constraint building Active CN104077144B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201410320943.2A CN104077144B (en) 2014-07-07 2014-07-07 Data race detection and evidence generation method based on multithreaded program constraint building
PCT/CN2015/081062 WO2016004808A1 (en) 2014-07-07 2015-06-09 Method for data contention testing and proof-generation, based on multithreaded program constraint construction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410320943.2A CN104077144B (en) 2014-07-07 2014-07-07 Data race detection and evidence generation method based on multithreaded program constraint building

Publications (2)

Publication Number Publication Date
CN104077144A true CN104077144A (en) 2014-10-01
CN104077144B CN104077144B (en) 2015-06-03

Family

ID=51598415

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410320943.2A Active CN104077144B (en) 2014-07-07 2014-07-07 Data race detection and evidence generation method based on multithreaded program constraint building

Country Status (2)

Country Link
CN (1) CN104077144B (en)
WO (1) WO2016004808A1 (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105183655A (en) * 2015-09-25 2015-12-23 南京大学 Android application program data race detection based on predictability analysis
WO2016004808A1 (en) * 2014-07-07 2016-01-14 西安交通大学 Method for data contention testing and proof-generation, based on multithreaded program constraint construction
CN106227656A (en) * 2016-07-18 2016-12-14 中国科学院软件研究所 A kind of data contention sample detecting method based on hardware and thread-local sequential
CN106294169A (en) * 2016-08-17 2017-01-04 华中科技大学 The detection of a kind of data contention based on semiology analysis virtual machine and playback method
CN106598845A (en) * 2016-11-18 2017-04-26 华中科技大学 Block HB (Happens-Before) based dynamic data race detection method and system
WO2017181628A1 (en) * 2016-04-19 2017-10-26 西安交通大学 Taint analysis method employing symbolic computation and used for dynamic parallel program
CN107992324A (en) * 2017-12-22 2018-05-04 南京大学 A kind of code search method based on constraint solving
CN108604192A (en) * 2016-02-08 2018-09-28 微软技术许可有限责任公司 Daily record is waited for call the thread transfer returned
CN110059014A (en) * 2019-04-28 2019-07-26 西安邮电大学 A kind of concurrent program data contention instruction-level localization method
CN110083539A (en) * 2019-04-29 2019-08-02 广州华多网络科技有限公司 A kind of data contention detection method and device
CN111431737A (en) * 2020-03-02 2020-07-17 苏州市职业大学 Predictive method for detecting data competition in software defined network
CN111858361A (en) * 2020-07-23 2020-10-30 中国人民解放军国防科技大学 Atomic violation defect detection method based on prediction and parallel verification strategies
CN113407447A (en) * 2021-06-15 2021-09-17 西安邮电大学 Self-adaptive lightweight dynamic hybrid data competition detection method
CN115080374A (en) * 2021-03-11 2022-09-20 中国科学院软件研究所 General concurrent defect detection method and system based on partial order relation
CN115794592A (en) * 2023-02-10 2023-03-14 南京邮电大学 Data competition detection method based on high-order function

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106201732B (en) * 2016-07-18 2019-05-14 电子科技大学 The line of removal data contention distributes parallel method in particle simulation algorithm is parallel

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760095A (en) * 2011-04-25 2012-10-31 清华大学 Dynamic data race detection method based on static shared variable recognition
CN103198025A (en) * 2012-01-04 2013-07-10 国际商业机器公司 Method and system form near neighbor data cache sharing
US20130275951A1 (en) * 2012-04-16 2013-10-17 International Business Machines Corporation Race detection for web applications

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8200474B2 (en) * 2008-05-08 2012-06-12 Nec Laboratories America, Inc. Dynamic model checking with property driven pruning to detect race conditions
CN103488563B (en) * 2013-09-05 2017-04-12 龙芯中科技术有限公司 Data race detection method and device for parallel programs and multi-core processing system
CN104077144B (en) * 2014-07-07 2015-06-03 西安交通大学 Data race detection and evidence generation method based on multithreaded program constraint building

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760095A (en) * 2011-04-25 2012-10-31 清华大学 Dynamic data race detection method based on static shared variable recognition
CN103198025A (en) * 2012-01-04 2013-07-10 国际商业机器公司 Method and system form near neighbor data cache sharing
US20130275951A1 (en) * 2012-04-16 2013-10-17 International Business Machines Corporation Race detection for web applications

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016004808A1 (en) * 2014-07-07 2016-01-14 西安交通大学 Method for data contention testing and proof-generation, based on multithreaded program constraint construction
CN105183655B (en) * 2015-09-25 2017-12-12 南京大学 Android application program data contention detection based on predictability analysis
CN105183655A (en) * 2015-09-25 2015-12-23 南京大学 Android application program data race detection based on predictability analysis
CN108604192B (en) * 2016-02-08 2021-11-19 微软技术许可有限责任公司 System, method, and medium for performing one or more tasks while waiting for an event to be recorded
CN108604192A (en) * 2016-02-08 2018-09-28 微软技术许可有限责任公司 Daily record is waited for call the thread transfer returned
WO2017181628A1 (en) * 2016-04-19 2017-10-26 西安交通大学 Taint analysis method employing symbolic computation and used for dynamic parallel program
CN106227656A (en) * 2016-07-18 2016-12-14 中国科学院软件研究所 A kind of data contention sample detecting method based on hardware and thread-local sequential
CN106227656B (en) * 2016-07-18 2018-07-17 中国科学院软件研究所 A kind of data contention sample detecting method based on hardware and thread-local sequential
CN106294169A (en) * 2016-08-17 2017-01-04 华中科技大学 The detection of a kind of data contention based on semiology analysis virtual machine and playback method
CN106294169B (en) * 2016-08-17 2018-08-03 华中科技大学 A kind of data contention detection and playback method based on semiology analysis virtual machine
CN106598845A (en) * 2016-11-18 2017-04-26 华中科技大学 Block HB (Happens-Before) based dynamic data race detection method and system
CN106598845B (en) * 2016-11-18 2019-04-12 华中科技大学 A kind of Data Race detection method and system based on block partial order
CN107992324A (en) * 2017-12-22 2018-05-04 南京大学 A kind of code search method based on constraint solving
CN110059014A (en) * 2019-04-28 2019-07-26 西安邮电大学 A kind of concurrent program data contention instruction-level localization method
CN110059014B (en) * 2019-04-28 2022-09-27 西安邮电大学 Concurrent program data competition instruction level positioning method
CN110083539A (en) * 2019-04-29 2019-08-02 广州华多网络科技有限公司 A kind of data contention detection method and device
CN110083539B (en) * 2019-04-29 2020-11-13 广州华多网络科技有限公司 Data competition detection method and device
CN111431737A (en) * 2020-03-02 2020-07-17 苏州市职业大学 Predictive method for detecting data competition in software defined network
CN111858361A (en) * 2020-07-23 2020-10-30 中国人民解放军国防科技大学 Atomic violation defect detection method based on prediction and parallel verification strategies
CN111858361B (en) * 2020-07-23 2023-07-21 中国人民解放军国防科技大学 Atomic violation defect detection method based on prediction and parallel verification strategy
CN115080374A (en) * 2021-03-11 2022-09-20 中国科学院软件研究所 General concurrent defect detection method and system based on partial order relation
CN113407447A (en) * 2021-06-15 2021-09-17 西安邮电大学 Self-adaptive lightweight dynamic hybrid data competition detection method
CN113407447B (en) * 2021-06-15 2022-09-27 西安邮电大学 Self-adaptive lightweight dynamic hybrid data competition detection method
CN115794592A (en) * 2023-02-10 2023-03-14 南京邮电大学 Data competition detection method based on high-order function
CN115794592B (en) * 2023-02-10 2023-07-04 南京邮电大学 Data competition detection method based on higher-order function

Also Published As

Publication number Publication date
CN104077144B (en) 2015-06-03
WO2016004808A1 (en) 2016-01-14

Similar Documents

Publication Publication Date Title
CN104077144B (en) Data race detection and evidence generation method based on multithreaded program constraint building
CN104077226B (en) Multithreaded program output uniqueness detection and evidence generation method based on program constraint building
Hazimeh et al. Magma: A ground-truth fuzzing benchmark
CN105955877B (en) A kind of dynamic parallel program stain analysis method based on sign computation
Lucia et al. Atom-aid: Detecting and surviving atomicity violations
Park et al. Java model checking
Şerbănuţă et al. Maximal causal models for sequentially consistent systems
EP2485149A1 (en) Symbolic execution and test generation for programs to be run on a graphic processor
Le Goues et al. Specification mining with few false positives
CN105868116A (en) Semantic mutation operator based test case generation and optimization method
Chen et al. Mc-checker: Detecting memory consistency errors in mpi one-sided applications
CN110245085B (en) Embedded real-time operating system verification method and system by using online model inspection
CN105468517B (en) A kind of mistake of statistics localization method based on Black-box testing Cases yojan
US8141082B2 (en) Node-based representation of multi-threaded computing environment tasks, and node-based data race evaluation
Křena et al. Coverage metrics for saturation-based and search-based testing of concurrent software
CN103294596A (en) Early warning method for contract-type software fault based on program invariants
Cai et al. LOFT: redundant synchronization event removal for data race detection
CN105138914A (en) Software security detection method for code reuse programming
JPWO2021124411A1 (en) A program that enables a logically coupled program to verify the legitimacy of an asynchronous algorithm that occurs at run time.
Jalbert et al. Using clone detection to identify bugs in concurrent software
Goodstein et al. Chrysalis analysis: Incorporating synchronization arcs in dataflow-analysis-based parallel monitoring
Zhang et al. Automated testing of definition-use data flow for multithreaded programs
Silva et al. LCCSS: A similarity metric for identifying similar test code
Li et al. A symbolic verifier for CUDA programs
Jiang et al. Detecting Transactional Bugs in Database Engines via {Graph-Based} Oracle Construction

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant