[SERVER-13988] mongo::sorter::nextFileNumber incorrectly assumes thread-safe initialization of function statics Created: 19/May/14 Updated: 04/Feb/15 Resolved: 10/Jan/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andrew Morrow (Inactive) | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Participants: |
| Description |
|
https://github.com/mongodb/mongo/blob/master/src/mongo/db/sorter/sorter.cpp#L768 In C++03, the initialization of function statics is not thread-safe (it is in C++11). While some compilers, notably GCC, actually implement thread-safe statics in C++03 mode by default unless asked not to, other compilers do not. On such platforms, it could be possible for the atomic to be initialized twice, probably leading to inconsistent results. |
| Comments |
| Comment by Andy Schwerin [ 10/Jan/15 ] |
|
If we raise the minimum supported compiler version on Windows to MSVC 2013R2, then all of our supported compilers provide thread-safe static initializers, anyhow. That's a better solution, given we already require MSVC 2013. |
| Comment by Mark Benvenuto [ 19/May/14 ] |
|
MSVC just added support for thread-safe function local statics in VS2013 Update 2. |