UNICORN: A Unified Approach for Localizing Non-deadlock Concurrency Bugs
1. UNICORN: A UNIFIED APPROACH
FOR LOCALIZING NON-DEADLOCK
CONCURRENCY BUGS
Sangmin Park, Richard Vuduc,
and Mary Jean Harrold
College of Computing
Georgia Institute of Technology
8. Concurrency Bugs Technique Studies Conclusion
Existing Techniques
Detect concurrency bugs — single variable
Data race
Limitation detectors [FastTrack, Eraser]
Order violation detectors [Falcon]
Don't detect concurrency bugs involving multiple
variables
Atomicity violation detectors [AVIO, Falcon, CTrigger]
Detect atomicity violations — multiple variables
Atomicity violation detectors [ColorSafe, AtomTracker]
Limitation
Don't detect order violations
Detect concurrency bugs — single and multiple
General bug detectors w/ statistical analysis
Limitation
[CCI, Bugaboo, Recon, DefUse]
Don't provide bug type information
8
9. Concurrency Bugs Technique Studies Conclusion
Overview
Concurrency Bugs
Order violation
Single-variable atomicity violation
Multi-variable atomicity violation
UNICORN Technique
Detects three types of concurrency bugs
Provides bug type information
Empirical Studies
Conclusion
9
10. Concurrency Bugs Technique Studies Conclusion
Bug: Order Violation
Thread 1 Thread 2
void main(…) { void * consumer (…) {
…
pthread_create(consumer);
…
W1
…
mutex = NULL;
…
Lock(mutex); R2
…
…
} }
* This example is from PBZip2. 10
11. Concurrency Bugs Technique Studies Conclusion
Bug: Single-Variable Atomicity
Thread 1 Thread 2
void new_file(…) { int mysql_insert(…) {
… // actual insert
saved_type = log_type; …
W1 log_type = CLOSED; if (log_type != CLOSED)
R2
… {
// update file LOG.write(…);
… }
W3 log_type = saved_type; …
… }
}
* This example is from MySQL-791. 11
12. Concurrency Bugs Technique Studies Conclusion
Bug: Multi-Variable Atomicity
Thread 1 Thread 2
int mysql_delete(…) { int mysql_insert(…) {
… …
Lock(X);
Lock(X);
W1 Table.remove (); Table.insert();
W2
Unlock(X); Unlock(X);
… …
Lock(Y); Lock(Y);
W4 LOG.write(); LOG.write(); W3
Unlock(Y); Unlock(Y);
… …
} }
* This example is from MySQL-169. 12
13. Concurrency Bugs Technique Studies Conclusion
Bug: Multi-Variable Atomicity
Thread 1 Thread 2
int mysql_delete(…) { int mysql_insert(…) {
… …
W1
Lock(X);
Table.remove ();
Lock(X);
Table.insert();
Note W2
Unlock(X); Unlock(X);
These
… three types of concurrency bugs are the
…
most important types of non-deadlock concurrency
Lock(Y); Lock(Y);
W4 bugs [Lu 08].
LOG.write(); LOG.write(); W3
Unlock(Y); Unlock(Y);
… …
} }
* This example is from MySQL-169. 13
20. Concurrency Bugs Technique Studies Conclusion
Step 1: Collect Pairs in Executions
Thread 1 Thread 2
int delete(…) { int insert(…) { I R R R R R R
Pair
D 1 2 3 4 5 6
… …
W1 (Tbl)-
Lock(X); Lock(X); 1
W2 (Tbl)
W1: Tbl(); W2: Tbl(); W3 (LOG)-
2
Unlock(X); Unlock(X); W4 (LOG)
… … W2 (Tbl)-
3
Lock(Y); Lock(Y); W1 (Tbl)
W4: LOG(); W3: LOG(); W4 (LOG)-
4
W3 (LOG)
Unlock(Y); Unlock(Y);
F P P F P P
… …
} }
20
21. Concurrency Bugs Technique Studies Conclusion
Step 2: Combine Pairs to Patterns
1. Set pairs to patterns for order violation
2. Combine pairs to patterns using sliding window
Sort pairs in time order
Combine two-pair-based patterns within pattern window
pairs, patterns, ranked-
P Step 1: Step 2: Step 3: patterns
outcomes outcomes
Collect Pairs Combine Pairs Rank
T Patterns
From Executions Into Patterns
21
23. Concurrency Bugs Technique Studies Conclusion
Step 2: Combine Pairs to Patterns
Thread 1 Thread 2 I R R R R R R
Pattern
D 1 2 3 4 5 6
int delete(…) { int insert(…) {
W1 (Tbl)-
1
… … W2 (Tbl)
Lock(X); Lock(X); W3 (LOG)-
2
W1: Tbl(); W2: Tbl(); W4 (LOG)
Unlock(X); Unlock(X); W2 (Tbl)-
3
W1 (Tbl)
… …
W4 (LOG)-
Lock(Y); Lock(Y); 4
W3 (LOG)
W4: LOG(); W3: LOG(); W1 (Tbl)-
Unlock(Y); Unlock(Y); 5
W2 (Tbl)-
W3 (LOG)-
… …
W4 (LOG)
} }
F P P F P P
23
24. Concurrency Bugs Technique Studies Conclusion
Step 3: Rank Patterns
Rank patterns
Compute suspiciousness of patterns
Jaccard formula [Abreu07]
failed (P)
suspiciousness(P) =
totalfailed + passed(P)
pairs, patterns, ranked-
P Step 1: Step 2: Step 3: patterns
outcomes outcomes
Collect Pairs Combine Pairs Rank
T Patterns
From Executions Into Patterns
24
25. Concurrency Bugs Technique Studies Conclusion
Step 3: Rank Patterns
failed (P)
suspiciousness(P) =
Thread 1 Thread 2 totalfailed + passed(P)
int delete(…) { int insert(…) { I R R R R R R
Pattern Susp
D 1 2 3 4 5 6
… …
W1 (Tbl)-
Lock(X); Lock(X); 1 0.5
W2 (Tbl)
W1: Tbl(); W2: Tbl(); W3 (LOG)-
2 0.5
Unlock(X); Unlock(X); W4 (LOG)
… … 3
W2 (Tbl)-
0.0
W1 (Tbl)
Lock(Y); Lock(Y);
W4 (LOG)-
W4: LOG(); W3: LOG(); 4 0.0
W3 (LOG)
Unlock(Y); Unlock(Y);
W1 (Tbl)-
… … W2 (Tbl)-
5 1.0
} } W3 (LOG)-
W4 (LOG)
F P P F P P
25
26. Concurrency Bugs Technique Studies Conclusion
Step 3: Rank Patterns
failed (P)
suspiciousness(P) =
Thread 1 Thread 2 totalfailed + passed(P)
int delete(…) { int insert(…) { I R R R R R R
Pattern Susp
D 1 2 3 4 5 6
… …
W1 (Tbl)-
Lock(X); Lock(X); 1 0.5
W2 (Tbl)
W1: Tbl(); W2: Tbl(); W3 (LOG)-
Summary Unlock(X); 2 0.5
Unlock(X); W4 (LOG)
… UNICORN… 3
W2 (Tbl)-
0.0
W1 (Tbl)
•
Lock(Y); Detects Lock(Y); access pairs
memory
W4 (LOG)-
•
W4: LOG(); Combines pairs into patterns
W3: LOG(); 4
W3 (LOG)
0.0
Unlock(Y); Unlock(Y);
• Ranks patterns w.r.t. suspiciousness
W1 (Tbl)-
… … W2 (Tbl)-
5 1.0
} } W3 (LOG)-
W4 (LOG)
F
P P
F P F P P
26
27. Concurrency Bugs Technique Studies Conclusion
Empirical Studies
Studies
1. Evaluate effectiveness of the technique
2. Measure distance of the pattern window
3. Evaluate efficiency of the technique (see paper)
Empirical Setup
Implemented in Java (Soot) and C++ (LLVM)
Evaluated on a set of subjects
27
28. Concurrency Bugs Technique Studies Conclusion
Subjects
Language Program LOC % Failed Bug Type
TimerThread 68 14.4 Order
LoadScript 110 49.8 Single-variable atomicity
MysqlLog 89 2.8 Single-variable atomicity
C++
Extracted JsString 95 1.4 Multi-variable atomicity
MysqlDelete 103 3.8 Multi-variable atomicity
MysqlSlave 94 0.4 Multi-variable atomicity
PBZip2 2k 2.8 Order
Mysql-791 372k 64.0 Single-variable atomicity
C++
Complete Aget 1.2k 49.0 Multi-variable atomicity
Mysql-169 334k 63.0 Multi-variable atomicity
StringBuffer 1.4k 22.3 Multi-variable atomicity
Java
Vector 9.5k 7.6 Multi-variable atomicity
28
29. Concurrency Bugs Technique Studies Conclusion
Study 1: Effectiveness
Goal
Todetermine how well UNICORN ranks the
pattern of the actual bug
Method
Set pair-window size to 5
Set pattern-window size to 100
Ran each subject 100 times and computed
suspiciousness and rankings
29
31. Concurrency Bugs Technique Studies Conclusion
Study 2: Pattern-window size
Goal
Toinvestigate the practicality of the pattern-
window size
Method
Computed the distance between the two pairs of
the actual concurrency bugs (using data from
Study 1)
Computed the median and maximum distances
31
33. Concurrency Bugs Technique Studies Conclusion
Future Work
Provide information to understand bugs
Problem: Several patterns ranked top together
Approach: In-depth analysis on the ranking
Provide information on test-suite
Problem: No study on effectiveness vs. test suite
Approach: Investigation on quality of test suite
Improve overhead
Problem: Significant overhead on monitoring
Approach: Use techniques such as sampling
33
34. Concurrency Bugs Technique Studies Conclusion
Contributions
UNICORN is the first unified technique that
detects memory-access pairs, combines pairs to get
patterns, and ranks patterns with respect to
suspiciousness
handles both single- and multi-variable violations
Empirical studies show that UNICORN
is effective in identifying patterns associated with
real bugs
is efficient
it needs small-/fixed-sized windows to find patterns
its runtime overhead comparable to other techniques
Questions 34