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

RACECHECK is full of races and should be removed

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.5
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
      None
    • Fully Compatible

      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.

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

              Created:
              Updated:
              Resolved: