Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-12663

Storage for DocumentStorage::emptyDoc is not guaranteed to have suitable alignment

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • Platforms E (01/08/16)

      The following code assumes that the emptyBytes char array is suitably aligned to store an object of type DocumentStorage, but no alignment is enforced:

              static const DocumentStorage& emptyDoc() {
                  static const char emptyBytes[sizeof(DocumentStorage)] = {0};
                  return *reinterpret_cast<const DocumentStorage*>(emptyBytes);
              }
      

      The code is also a strict aliasing violation.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: