Peli at RiSE

Sebastian Burckhardt - Data Race Detection with CHESS

Download this episode

Download Video

Description

Sebastian Burckhardt gives a short tutorial of some of the new features of CHESS: data race detection and ChessBoard. CHESS is a concurrency testing tool takes a concurrent unit test and executes it with different thread schedules. Sebastian explains us how CHESS can detect data races, a very subtle kind of concurrency bug. You'll also learn how to drill into concurrency issues using the ChessBoard, a little application designed to drill and investigate concurrent tests.

The Research in Software Engineering team (RiSE) coordinates Microsoft's research in Software Engineering in Redmond, USA.

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • aL_

      cool stuff Smiley

      but im a little bit confused.. why didnt the old chess find this bug? if it ran with all the combinations of context switches, wouldnt the assert be false?

    • Tom ball

      CHESS only places schedule points at synchronization points (calls to System.Threading API, volatiles, interlocked increments). So you need data race detection to uncover more bugs. CHESS now has an option /preemptaccesses that places schedule points before every read/write. However, as currently implemented, this has high overhead.

      -- Tom

    • hack2rootho​tmai

      I spent a couple of time to build a good, working solution for .NET 2.0 / 3.5, so you do not need to wait and install .NET 4.0

      Can you test it using CHESS?

      Abstract:

          public abstract class PluginBaseWorkItem<T>

          {

              private static object _sync = new object();

              private T _item;

              public T Item { get { return _item; } }

              public void Run()

              {

                  List<WaitHandle> _waitHandles = new List<WaitHandle>();

                  for (int i = 0; i < TaskCount; i++)

                  {

                      _waitHandles.Add(new AutoResetEvent(false));

                  }

                  for (int i = 0; i < TaskCount; i++)

                  {

                      ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessHandle), _waitHandles[i]);

                  }

                  WaitHandle.WaitAll(_waitHandles.ToArray());

              }

              protected abstract void ProcessItem();

              protected void SetValue(T item)

              {

                  _item = item;

              }

              protected T GetValue()

              {

                  return _item;

              }

              protected virtual int TaskCount { get { return Environment.ProcessorCount; } }

              private void Process()

              {

                  ProcessItem();

              }

              private void ProcessHandle(object sync)

              {

                  AutoResetEvent waitHandle = (AutoResetEvent)sync;

                  Process();

                  waitHandle.Set();

              }

          }

       

               private class WorkItem : PluginBaseWorkItem<Puzzle>

              {

                  protected override void ProcessItem()

                  {

                      DlxEngine engine = new DlxEngine();

                      Puzzle value = engine.Generate(20);

                      lock (this)

                      {

                          Puzzle item = GetValue();

                          if (item == null || value.Rating > item.Rating)

                          {

                              SetValue(value);

                          }

                      }

                  }

              }

       

              public static IPuzzle Create()

              {

                  WorkItem workItem = new WorkItem();

                  workItem.Run();

                  IPuzzle puzzle = workItem.Item;

                  return Create(puzzle.Text, puzzle.Seed);

              }

    • garrettvm

      Excellent post! Great use of Picture-in-picture technology. Improves user experience a lot

      and

      seems to be a bug in the comment recording. my comment box showed up blank while the comment showed up under hack2roothotmai??!!

    • agence

      I tested it, it works !
      Many thanks for this excellent post !!!
      --

    • michel24

      Good job ... thank you for this help.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.