[SERVER-5739] Race condition in SOMETIMES/MONGO_SOMETIMES macros Created: 01/May/12 Updated: 15/Dec/18 Resolved: 16/Nov/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | 4.1.6 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Andy Schwerin | Assignee: | Billy Donahue |
| Resolution: | Done | Votes: | 0 |
| Labels: | neweng, platforms-interns-2017 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Operating System: | ALL | ||||||||||||
| Sprint: | Dev Tools 2018-11-19 | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
The definition of MONGO_SOMETIMES contains a race condition. It's current implementation is as follows:
Plain-and-simple not thread safe. |
| Comments |
| Comment by Githook User [ 16/Nov/18 ] |
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: Switch to using C++ instead of macros. |
| Comment by Andrew Morrow (Inactive) [ 22/Dec/16 ] |
|
Note that when this ticket was filed, there were in fact two races in the implemenation:
While the first of these issues was addressed by our move to C++11 and modernization of the toolchain, the latter has not been. The best solution is to probably declare the occasion variable as a static std::atomic. We should consider, when fixing this, whether these should be 32-bit or 64-bit counters, and use the appropriate fixed-width underlying type for the atomics. |