Multithreading Debugging – Is Static Analysis Reliable for Reproducing Concurrency Bugs?

debuggingmultithreadingstatic analysis

I've inherited some Java code which I suspect harbours some concurrency bugs when synchronizing between a thread that queries data and an IO event that updates the same data. I'm trialling a static analysis tool called ThreadSafe which indeed detects various concurrency issues (i.e. field accessed from asynchronously invoked method without synchronization and Inconsistent synchronization of accesses to a collection).

After discovering how difficult it is to reproduce data races reliably by writing unit tests, I wondered if it's advisable to depend on ThreadSafe to "reproduce" the bugs reliably?
What I'm asking is, is it safe to depend on the static analysis tool to tell me when I've fixed the bugs? (Of course, to fix the bugs I will need to understand each one in context).

Best Answer

Answering your first question:

http://www.contemplateltd.com/threadsafe/faq#non-checkers

"What kinds of concurrency defects does ThreadSafe not look for?

  • We do not yet include support for all of java.util.concurrent. Specifically, ThreadSafe does not check for misuse of the advanced synchronization facilities provided by java.util.concurrent, for example the java.util.concurrent.atomic package. Nor does it currently include any checkers for mistakes that may occur when writing parallel programs using the Fork-Join framework.

  • Finding bugs in intricate lock-free algorithms requires analysis technology that does not scale well. Such algorithms should be left to specialized concurrency experts. ThreadSafe can be configured to find defects in applications that use libraries containing such algorithms.

  • Which analyses we include in new releases of ThreadSafe is dictated both by what is possible using analysis technology that is mature enough for integration into a usable product, and by the features and concurrency defects that we see often in ‘average’ Java programs.

  • If you have a Java concurrency problem that is not currently covered by ThreadSafe, Contemplate’s Java concurrency specialists may be able to help by adding custom configuration to ThreadSafe and/or by use of advanced analysis technology that is not yet mature enough for integration into ThreadSafe."