[SERVER-14855] RACECHECK is full of races and should be removed Created: 11/Aug/14  Updated: 18/Aug/14  Resolved: 12/Aug/14

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 2.7.5

Type: Improvement Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 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.



 Comments   
Comment by Githook User [ 12/Aug/14 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: SERVER-14855 Remove RACECHECK and race.h; they introduce races
Branch: master
https://github.com/mongodb/mongo/commit/fae7c52d21cacdc97c898d17b95e4322f8a9bb87

Generated at Thu Feb 08 03:36:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.