(Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves...
Transcript of (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves...
![Page 1: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/1.jpg)
1
Program Testing and Analysis:
Testing Concurrent Programs(Part 2)
Dr. Michael Pradel
Software Lab, TU Darmstadt
![Page 2: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/2.jpg)
2
Warm-up Quiz
var x = 5;var y = Number(5);var z = new Number(5);x.foo = "bar"; y.foo = "bar"; z.foo = "bar";console.log(x.foo);console.log(y.foo);console.log(z.foo);
What does the following code print?
barundefinedbar
undefinedundefinedundefined
barbarbar
Some-thingelse
![Page 3: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/3.jpg)
2
Warm-up Quiz
var x = 5;var y = Number(5);var z = new Number(5);x.foo = "bar"; y.foo = "bar"; z.foo = "bar";console.log(x.foo);console.log(y.foo);console.log(z.foo);
What does the following code print?
barundefinedbar
undefinedundefinedundefined
barbarbar
Some-thingelse
”undefined” (x and y areprimitive values, whichcannot have properties)
”bar” (z is an object)
![Page 4: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/4.jpg)
3
Outline
1. Introduction
2. Dynamic Data Race Detection
3. Testing Thread-Safe Classes
4. Exploring Interleavings
Mostly based on these papers:
� Eraser: A Dynamic Data Race Detector for MultithreadedPrograms, Savage et al., ACM TOCS, 1997
� Fully Automatic and Precise Detection of Thread SafetyViolations, Pradel and Gross, PLDI 2012
� Finding and Reproducing Heisenbugs in ConcurrentPrograms, Musuvathi et al., USENIX 2008
![Page 5: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/5.jpg)
4
Thread Safety
� Popular way to encapsulate the challenges ofconcurrent programming: Thread-safe classes
� Class ensures correct synchronization
� Clients can use instances as if they were alone
� Rest of program can treat implementation ofthread-safe class as a blackbox
![Page 6: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/6.jpg)
5
Thread Safety (2)
“behaves correctly when accessedfrom multiple threads ... with noadditional synchronization ... (inthe) calling code” page 18
![Page 7: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/7.jpg)
5
Thread Safety (2)
“behaves correctly when accessedfrom multiple threads ... with noadditional synchronization ... (inthe) calling code” page 18
![Page 8: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/8.jpg)
5
Thread Safety (2)
“behaves correctly when accessedfrom multiple threads ... with noadditional synchronization ... (inthe) calling code” page 18
![Page 9: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/9.jpg)
5
Thread Safety (2)
“behaves correctly when accessedfrom multiple threads ... with noadditional synchronization ... (inthe) calling code”
“operations ... behave as if they occurin some serial order that is consistentwith the order of the method callsmade by each of the individualthreads”
page 18
StringBuffer API documentation, JDK 6
![Page 10: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/10.jpg)
5
Thread Safety (2)
“behaves correctly when accessedfrom multiple threads ... with noadditional synchronization ... (inthe) calling code”
“operations ... behave as if they occurin some serial order that is consistentwith the order of the method callsmade by each of the individualthreads”
page 18
StringBuffer API documentation, JDK 6
![Page 11: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/11.jpg)
6
Example from JDK
StringBuffer b = new StringBuffer()
b.append("a")
b.append("b")
b.append("c")
Thread 1 Thread 2
![Page 12: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/12.jpg)
6
Example from JDK
StringBuffer b = new StringBuffer()
b.append("a")
b.append("b")
b.append("c")
Thread 1 Thread 2
Quiz: What can be the content of b ifStringBuffer is thread-safe?
![Page 13: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/13.jpg)
6
Example from JDK
StringBuffer b = new StringBuffer()
b.append("a")
b.append("b")
b.append("c")
Thread 1 Thread 2
"abc" 3 "cab" 3 "acb" 3 "ac" 7 "bac" 7
![Page 14: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/14.jpg)
6
Example from JDK
StringBuffer b = new StringBuffer()
b.append("a")
b.append("b")
b.append("c")
Thread 1 Thread 2
"abc" 3 "cab" 3 "acb" 3 "ac" 7 "bac" 7
![Page 15: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/15.jpg)
6
Example from JDK
StringBuffer b = new StringBuffer()
b.append("a")
b.append("b")
b.append("c")
Thread 1 Thread 2
"abc" 3 "cab" 3 "acb" 3 "ac" 7 "bac" 7
![Page 16: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/16.jpg)
6
Example from JDK
StringBuffer b = new StringBuffer()
b.append("a")
b.append("b")
b.append("c")
Thread 1 Thread 2
"abc" 3 "cab" 3 "acb" 3 "ac" 7 "bac" 7
![Page 17: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/17.jpg)
6
Example from JDK
StringBuffer b = new StringBuffer()
b.append("a")
b.append("b")
b.append("c")
Thread 1 Thread 2
"abc" 3 "cab" 3 "acb" 3 "ac" 7 "bac" 7
![Page 18: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/18.jpg)
7
Testing Thread-Safe Classes
� Correctness of program relies on thread safety ofspecific classes
� But: What if the class is actually not thread-safe?
� ConTeGe = Concurrent Test Generator
� Creates multi-threaded unit tests
� Detects thread safety violations by comparingconcurrent behavior against linearizations
![Page 19: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/19.jpg)
8
Example Bug from JDK
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
![Page 20: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/20.jpg)
8
Example Bug from JDK
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
IndexOutOfBoundsException
Issue #7100996 in Oracle’s bug tracker
!
![Page 21: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/21.jpg)
9
ConTeGe
Bug
Classundertest(CUT)
Execute
Thread safetyoracle
Generate aconcurrent test
![Page 22: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/22.jpg)
9
ConTeGe
Bug
Classundertest(CUT)
Execute
Thread safetyoracle
Generate aconcurrent test
![Page 23: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/23.jpg)
9
ConTeGe
Bug
Classundertest(CUT)
Execute
Thread safetyoracle
Generate aconcurrent test
![Page 24: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/24.jpg)
10
Generating Concurrent Tests
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Example:
![Page 25: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/25.jpg)
10
Generating Concurrent Tests
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Sequential prefix:
Create and set upCUT instance
Example:
![Page 26: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/26.jpg)
10
Generating Concurrent Tests
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Concurrent suffixes:
Use shared CUTinstance
Example:
![Page 27: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/27.jpg)
11
Test Generation Algorithm
1. Create prefix� Instantiate CUT
� Call methods
2. Create suffixes for prefix� Call methods on shared CUT instance
3. Prefix + two suffixes = test
Selection of methods similar tofeedback-directed test generation
![Page 28: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/28.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
![Page 29: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/29.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Randomlyselect aconstructor
![Page 30: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/30.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Randomlyselect aconstructor
![Page 31: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/31.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
After adding a call:Execute
![Page 32: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/32.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
After adding a call:Execute
3
![Page 33: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/33.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Randomlyselect amethod
![Page 34: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/34.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Randomlyselect amethod
b.append(/* String */)
![Page 35: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/35.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
b.append(/* String */)
Arguments:a) Take available objectb) Call method returning
required typec) Random value
![Page 36: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/36.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Arguments:a) Take available objectb) Call method returning
required typec) Random value
![Page 37: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/37.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
After adding a call:Execute
![Page 38: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/38.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
After adding a call:Execute
3
![Page 39: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/39.jpg)
12
Creating a Prefix
1. Create prefix� Instantiate CUT
� Call methods
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
![Page 40: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/40.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
![Page 41: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/41.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)
![Page 42: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/42.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)
Randomlyselect amethod
![Page 43: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/43.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)
Randomlyselect amethod
b.insert(/* int */, /* CharSequence */)
![Page 44: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/44.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)b.insert(/* int */, /* CharSequence */)
Arguments:a) Take available objectb) Call method returning
required typec) Random value
![Page 45: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/45.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)b.insert(-5, b)
Arguments:a) Take available objectb) Call method returning
required typec) Random value
![Page 46: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/46.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)b.insert(-5, b)
After adding a call:Execute
![Page 47: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/47.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)b.insert(-5, b)
After adding a call:Execute
!
![Page 48: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/48.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)b.insert(/* int */, /* CharSequence */)
Arguments:a) Take available objectb) Call method returning
required typec) Random value
![Page 49: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/49.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)
Arguments:a) Take available objectb) Call method returning
required typec) Random value
![Page 50: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/50.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)
After adding a call:Execute
![Page 51: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/51.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)
After adding a call:Execute
3
![Page 52: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/52.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b)
![Page 53: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/53.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
![Page 54: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/54.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
After adding a call:Execute
![Page 55: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/55.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
After adding a call:Execute
3
![Page 56: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/56.jpg)
13
Creating Suffixes
2. Create suffixesfor prefix
� Call methods onshared CUT instance
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
![Page 57: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/57.jpg)
14
Creating a Test
3. Prefix + two suffixes = test
![Page 58: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/58.jpg)
14
Creating a Test
3. Prefix + two suffixes = test
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
![Page 59: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/59.jpg)
14
Creating a Test
3. Prefix + two suffixes = test
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
Spawn new threadfor each suffix
![Page 60: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/60.jpg)
15
Approach
Bug
Classundertest(CUT)
Execute
Thread safetyoracle
Generate aconcurrent test
![Page 61: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/61.jpg)
15
Approach
Bug
Classundertest(CUT)
Execute
Thread safetyoracle
Generate aconcurrent test
![Page 62: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/62.jpg)
16
Thread Safety Oracle
Does the test executionexpose a thread safetyviolation?
� Focus on exceptionsand deadlocks
� Compare concurrentexecution tolinearizations
![Page 63: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/63.jpg)
17
Linearizations
� Put all calls into one thread� Preserve order of calls within a thread
![Page 64: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/64.jpg)
17
Linearizations
� Put all calls into one thread� Preserve order of calls within a thread
21 3
![Page 65: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/65.jpg)
17
Linearizations
213
2
13
21
3
� Put all calls into one thread� Preserve order of calls within a thread
21 3
![Page 66: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/66.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
3
3
![Page 67: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/67.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
Execute concurrently
3
3
![Page 68: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/68.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
Exception ordeadlock? 3
3
![Page 69: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/69.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
Execute linearization
3
3
![Page 70: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/70.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
Samefailure?
3
3
![Page 71: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/71.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
Execute linearization
3
3
![Page 72: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/72.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
Samefailure?
3
3
![Page 73: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/73.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
3
3
All linearizationschecked
![Page 74: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/74.jpg)
18
The Oracle
Exception ordeadlock?
Execute concurrently
No
Yes
Yes
No Thread safetyviolation
Samefailure?
Execute linearization All linearizationschecked
Thread safetyviolation
3
3
![Page 75: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/75.jpg)
19
Example
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
![Page 76: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/76.jpg)
19
Example
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
Thread 1 Thread 2
!
![Page 77: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/77.jpg)
19
Example
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
StringBuffer b = ..
b.append("abc")
b.insert(1, b)
b.deleteCharAt(1) 3
Thread 1 Thread 2
!
![Page 78: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/78.jpg)
19
Example
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
StringBuffer b = ..
b.append("abc")
b.insert(1, b)
b.deleteCharAt(1) 3
Thread 1 Thread 2
StringBuffer b = ..
b.append("abc")
b.deleteCharAt(1)
b.insert(1, b) 3
!
![Page 79: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/79.jpg)
19
Example
StringBuffer b = new StringBuffer()
b.append("abc")
b.insert(1, b) b.deleteCharAt(1)
StringBuffer b = ..
b.append("abc")
b.insert(1, b)
b.deleteCharAt(1) 3
Thread 1 Thread 2
StringBuffer b = ..
b.append("abc")
b.deleteCharAt(1)
b.insert(1, b) 3
!Thread safety violation
![Page 80: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/80.jpg)
20
Properties of the Oracle
Sound but incomplete *
� All reported violations are real� Cannot guarantee thread safety
Independent of bug type� Data races� Atomicity violations� Deadlocks
* with respect to incorrectness
![Page 81: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/81.jpg)
21
Implementation & Results
� Implemented for Java classes
� Applied to popular thread-safe classesfrom JDK, Apache libraries, etc.
� Found 15 concurrency bugs, includingpreviously unknown problems in JDK
� Takes between several seconds andseveral hours (worst case: 19 hours)
![Page 82: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/82.jpg)
22
Open Challenges
� How to generate tests that are likely to triggerbugs? (Currently: random decisions)
� Static analysis to find potential bugs; focus on thoseduring test generation
� Use feedback from test execution to steer testgeneration towards not yet explored behavior
� How to generate tests for larger pieces ofconcurrent software, e.g., entire libraries orprograms?
![Page 83: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/83.jpg)
22
Open Challenges
� How to generate tests that are likely to triggerbugs? (Currently: random decisions)
� Static analysis to find potential bugs; focus on thoseduring test generation
� Use feedback from test execution to steer testgeneration towards not yet explored behavior
� How to generate tests for larger pieces ofconcurrent software, e.g., entire libraries orprograms?
Hint: Opportunities for master theses
![Page 84: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/84.jpg)
23
Outline
1. Introduction
2. Dynamic Data Race Detection
3. Testing Thread-Safe Classes
4. Exploring Interleavings
Mostly based on these papers:
� Eraser: A Dynamic Data Race Detector for MultithreadedPrograms, Savage et al., ACM TOCS, 1997
� Fully Automatic and Precise Detection of Thread SafetyViolations, Pradel and Gross, PLDI 2012
� Finding and Reproducing Heisenbugs in ConcurrentPrograms, Musuvathi et al., USENIX 2008
![Page 85: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/85.jpg)
24
Scheduling Non-Determinism
� A single program executed with a single inputmay have many different interleavings
� Scheduler decides interleavingsnon-deterministically
� Some interleavings may expose bugs, othersexecute correctly (”Heisenbugs”)
� Challenge: How to explore different interleavings?How to detect buggy interleavings?
![Page 86: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/86.jpg)
25
CHESS in a Nutshell
� A user mode scheduler that controlsall scheduling non-determinism
� Guarantees:� Every program run takes a new thread
interleaving� Can reproduce the interleaving for every run
� Systematic but non-exhaustiveexploration of the set of possibleinterleavings
![Page 87: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/87.jpg)
26
Tree of Interleavings
� Search space of possibleinterleavings: Represent as a tree
� Nodes = points of scheduling decision
� Edges = decisions taken
� Each path = one possible schedule
![Page 88: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/88.jpg)
27
Example
// bank account
int balance = 10;
// deposit money
int tmp1 = balance;
balance = tmp1 + 5;
// withdraw money
int tmp2 = balance;
balance = tmp2 - 7;
Thread 1 Thread 2
![Page 89: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/89.jpg)
1
![Page 90: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/90.jpg)
29
State Space Explosion
Thread 1:
instr. 1instr. 2...instr. k
n threads
k instructions
� Number ofinterleavings: O(nn·k)
� Exponential in both n
and k
� Typically:n < 10, k > 100
� Exploring allinterleavings does notscale to largeprograms (i.e., large k)
Thread 2:
instr. 1instr. 2...instr. k
![Page 91: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/91.jpg)
30
Preemption Bounding
� Limit exploration to schedules with a smallnumber c of preemptions� Preemption = Context switches forced by the
scheduler
� Number of schedules: O((n2 · k)c · n!)� Exponential in c and n, but not in k
� Based on empirical observation: Mostconcurrency bugs can be triggered with few (< 2)preemptions
![Page 92: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/92.jpg)
31
Implementation and Results
� Implemented via binary instrumentation
� Applied to eight mid-size and large systems (upto 175K lines of code),
� Found a total of 27 bugs
� Major benefit over stress testing: Once a failure isdetected, can easily reproduce and debug it
![Page 93: (Part 2) Testing Concurrent Programs Program Testing and ... · Thread Safety (2) “behaves correctly when accessed from multiple threads ... with no additional synchronization ...](https://reader034.fdocuments.net/reader034/viewer/2022052011/60260a1fd726a224333beb5a/html5/thumbnails/93.jpg)
32
Summary
� Concurrent programming is inevitable
� Writing correct concurrent programsis hard
� Techniques to detect concurrencybugs� Dynamic data race detection� Test generation and thread safety checking� Systematic exploration of interleavings