title: Testing approach for multi-threaded software
body: <p>I have a piece of mature geospatial software that has recently had areas rewritten to take better advantage of the multiple processors available in modern PCs.  Specifically, display, GUI, spatial searching, and main processing have all been hived off to seperate threads.  The software has a pretty sizeable GUI automation suite for functional regression, and another smaller one for performance regression.  While all automated tests are passing, I'm not convinced that they provide nearly enough coverage in terms of finding bugs relating race conditions, deadlocks, and other nasties associated with multi-threading.  What techniques would you use to see if such bugs exist?  What techniques would you advocate for rooting them out, assuming there are some in there to root out? </p>
  
  <p>What I'm doing so far is running the GUI functional automation on the app running under a debugger, such that I can break out of deadlocks and catch crashes, and plan to make a bounds checker build and repeat the tests against that version.  I've also carried out a static analysis of the source via PC-Lint with the hope of locating potential dead locks, but not had any worthwhile results.  </p>
  
  <p>The application is C++, MFC, mulitple document/view, with a number of threads per doc.  The locking mechanism I'm using is based on an object that includes a pointer to a CMutex, which is locked in the ctor and freed in the dtor.  I use local variables of this object to lock various bits of code as required, and my mutex has a time out that fires my a warning if the timeout is reached.  I avoid locking where possible, using resource copies where possible instead.</p>
  
  <p>What other tests would you carry out?   </p>
  
  <p><strong>Edit:</strong> I have cross posted this question on a number of different testing and programming forums, as I'm keen to see how the different mind-sets and schools of thought would approach this issue.  So apologies if you see it cross-posted elsewhere.  I'll provide a summary links to responses after a week or so</p>