Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14855

RACECHECK is full of races and should be removed

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 2.7.5
    • Internal Code
    • None
    • Fully Compatible

    Description

      The RACECHECK macro introduces a function scoped static object of type race::Block in an attempt to detect races. However, prior to C++11, initialization of function scoped statics is not thread-safe, so there is no guarantee that the Block object is properly constructed by the first thread before another reads from it, nor is there any assurance that the Block object won't be constructed twice.

      Furthermore, the implementation of race::Block uses a volatile int to attempt to track accesses, but does not use atomics or fences to ensure load/store ordering and write visibility, so introduces races of its own.

      RACECHECK cannot portably work as advertised, so we should remove it. If we want to detect races, we should use a modern race detector like ThreadSanitizer, DRD, Helgrind, etc.

      Attachments

        Activity

          People

            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: