Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 10. Testing and debugging multit... > Techniques for locating concurrency-... - Pg. 303

Techniques for locating concurrency-related bugs 303 issues, the visible symptoms of the problem (such as random crashes or incorrect out- put) can manifest anywhere in the code--the code may overwrite memory used by another part of the system that isn't touched until much later. The fault will then man- ifest in code completely unrelated to the location of the buggy code, possibly much later in the execution of the program. This is the true curse of shared memory sys- tems--however much you try to limit which data is accessible by which thread and try to ensure that correct synchronization is used, any thread can overwrite the data being used by any other thread in the application. Now that we've briefly identified the sorts of problems we're looking for, let's look at what you can do to locate any instances in your code so you can fix them. 10.2 Techniques for locating concurrency-related bugs In the previous section we looked at the types of concurrency-related bugs you might see and how they might manifest in your code. With that information in mind, you can then look at your code to see where bugs might lie and how you can attempt to determine whether there are any bugs in a particular section. Perhaps the most obvious and straightforward thing to do is look at the code. Although this might seem obvious, it's actually difficult to do in a thorough way. When you read code you've just written, it's all too easy to read what you intended to write rather than what's actually there. Likewise, when reviewing code that others have writ-