[SERVER-14198] Std::set<pointer> and Windows Heap Allocation Reuse produces non-deterministic results Created: 07/Jun/14 Updated: 02/Aug/18 Resolved: 09/Jun/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | 2.7.1 |
| Fix Version/s: | 2.6.4, 2.7.2 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Mark Benvenuto | Assignee: | Mark Benvenuto |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Backport Completed: | |||||||||||||
| Sprint: | Server 2.7.2 | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
std::set<pointer> based types are unreliable if the memory addresses are not unique, but could be reused during the lifetime of the process. This also applies to other types such as like std::map. In the dump below from Visual Studio 2013 of the mmfiles std::set, we see element 6 contains a paradox.
The inner class of type mongo::MemoryMappedFile contains a fd of 0x370 while the outer class of mongo::WindowsFlushable contains a fd of 0x270. We assume the following invariant will hold: This is logical since mongo::WindowsFlushable::_fd is simply a copy of mongo::MemoryMappedFile::fd. But this invariant will fail to hold under the following scenario.
which will incorrectly pass because it believes the file is still allocated. In this example, I can validate that this is not just dirty memory because
|
| Comments |
| Comment by Githook User [ 16/Jun/14 ] |
|
Author: {u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}Message: In std::set<Pointer>, Pointer to a memory address is not a unique key. (cherry picked from commit af4f086490d6ae51aa0c252df26751385683eaaa) |
| Comment by Githook User [ 09/Jun/14 ] |
|
Author: {u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}Message: In std::set<Pointer>, Pointer to a memory address is not a unique key. |