Exceptions and Mistakes CSE788 John Eisenlohr
Big Question How can we improve the quality of concurrent software?
Focus of this 788 Detecting concurrent program bugs automatically More Specific Question: How can we make this approach as effective as possible?
Two Answers 1)“Learning From Mistakes” : focus on the most common concurrency bugs. 2)“A Case for System Support”: Use Concurrency Exceptions to find more bugs and give more information when they are found.
“Learning” looks at three areas: 1)What should automatic bug detection systems be looking for? 2)How should we test concurrent software? 3)What are some features a good concurrent programming language should have?
“Learning” methodology Look at the bug report databases of four open source applications. Find the fixed concurrency bugs. Categorize them.
Generating the bug data Bug databases contain over 500,000 bugs.
Bug Sources Randomly selected 500 concurrency bug reports. Manually selected bugs that were caused by programmers' wrong assumptions about concurrent execution.
Categorizing the bugs Four Areas: Bug Pattern Manifestation Bug Fix Strategy Bug Avoidance
Bug Pattern Definitions
Atomicity Violation Example (CHECK THEN ACT)
Order Violation Example
Order Violation Example 2
Bug Patterns – results
Bug Patterns – findings
Bug Manifestation Definitions
Manifestation – Results 1
Manifestation – Results 2
Manifestation – Findings
Fix Strategy Definitions
Fix Strategy – Results
Fix Strategy – Findings
Bug Avoidance – Results
Bug Avoidance – Findings 1
Bug Avoidance – Findings 2
“Concurrency Exceptions” Concurrency errors should be treated as exceptions, like divide-by-zero. Make non-determinism in multi-threaded execution more manageable Improve the debugging process During development In the field
“Concurrency Exceptions” Propose to throw exceptions for three types of concurrency errors: 1)Sequential Consistency Violation 2)Locking Discipline Violation 3)Atomicity Violation
Sequential Consistenency Exception
Locking Discipline Exception
Atomicity Exception
Required Support for Concurrent Exceptions
Programming Language Support Sequential Consistency: Convey information about synchronization operations to the violation detection mechanism. Detection mechanism can determine whether the execution is guaranteed to be SC.
Programming Language Support Locking Language declares locks, shared data and the associations between them Exception is raised if data is accessed but thread does not hold appropriate lock.
Programming Language Support Atomicity Programmer specifies atomic sections of code. System determines if an execution violates this specification and throws exception
Delivering Exceptions Which thread should receive the exception? What are the guarantees of process state when exception is thrown?
Which thread? The one that is about to issue the memory operation that triggers the exception
State Guarantees Make multiprocessor execution fully deterministic Guarantee the state of only the thread which receives the exception
Did the authors of “A Case” make a convincing case? What are the advantages of throwing an exception in response to a concurrency bug
In “A Case”, how useful is the atomicity detection? Requires programmer to specify atomic sections of code, then checks whether the locking mechanism respects atomicity.
Does the proposal in “A Case” detect the most common programming errors? How about ordering violations? Should there be more effort put into automatically detecting ordering violations?
How useful are the results from “Learning” given the number and type of applications and the number of bugs? Should different types of applications be analyzed? More bugs? The bug database had over half a million entries, and they analyzed 105.
Does the bug fix in Figure 8 of “Learning” make sense?
Is there anything special about bugs that have been found and fixed; i.e., is this study biased towards a certain type of bug? Can you think of a better way to generate bug data? Automatic bug finders? Concurrency Exceptions?
Do you think the conclusions drawn by the authors of “Learning” make sense? Focus on atomicity violation and order violation. New bug-detection techniques to find order violation? Test pairs of threads instead of groups?
Was anything in “Learning” surprising? Most bugs are not fixed by adding or changing locks? The percentage of bugs that can be addressed by TM?
Of the following four categories, where should most effort be put? Automatic Bug Detection Testing techniques Concurrent Language Design Software Engineering Disciplines for Concurrent Programming
Should we strive for Deterministic Shared Memory Processing? How would that affect the conclusions drawn by “Learning”?