-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code
-
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.