Tuesday 28 October 2008, 8:22 PM
Heisenbugs
Chess is designed to solve this problem. It will help if you have unit tests for your application (you do, of course?), which Chess then runs multiple times, varying the timing across your threads, looking looking for problems such as data races. You can give some clues, but it will pre-empt scheduling and attempt to reschedule when variables which have been marked as being volatile change, or when the programmer uses mutexs to attempt to force threads to run singularly.
The demos (which I videoed but I'm have problem getting off my camera) are impressive, using PLINQ to generate a parallel program with a deliberate data race problem. The code usually runs correctly, but once in, say, a 1000 times, the code will fail. Using Chess as host for your tests it alters the order the threads run in (presumably by doing a relative drift), and the test eventually fails.
When the test fails, it generates some C# attributes you can then use to decorate your test methods (it seemed be a 100-200 character stream), which means that the test should always fail. What I'm not quite clear about is how robust these relative timing changes are in the face of your changing code, but its a good start.
Currently the testing environment is hosted using team foundation system and using the Microsoft unit-testing framework. For those folks who are using the downlevel Visual Studio editions, there is also a command-line version available.
It's not currently available, but I was told it would be in a couple of weeks. In the meanwhile, the project website is here: http://research.microsoft.com/chess/
Comments on this post
Thank you for posting this note. I have had this very same problem. It seems to crop up when attempting to read a networked share drive that is sometimes busy.
To add a comment, fill out the form below


