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

Change TrackingAllocator to use aligned_alloc to enforce that 128-bit types will be 16-byte aligned no matter default alignment.

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Service Arch
    • v8.0
    • Service Arch 2024-04-15, Service Arch 2024-04-29

      Premise

      We use 128-bit types in the BSONColumnBuilder. On x86, we need 128-bit types to be 16-byte aligned (a couple of sources: 1, 2, 3, 4). Separately, we overload operator new in the TrackingAllocator.

      Problematic Change

      We set {}STDCPP_DEFAULT_NEW_ALIGNMENT{} (C++17 macro) to 8 bytes instead of 16 to make TCMalloc faster. Setting this macro causes operator new/delete to align to 8 bytes instead of 16 bytes (malloc is still 16). This causes segfaults when dealing with 128-bit types on x86 due to misaligned access (other examples of failure in the wild: 1, 2, 3).

      Proposed Solution

      Force the TrackingAllocator to use aligned_alloc and pass in alignof(T), since abseil int128 types are already indicated to align to 16 bytes.

            Assignee:
            blake.oler@mongodb.com Blake Oler
            Reporter:
            blake.oler@mongodb.com Blake Oler
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: