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

Building without NDEBUG defined causes tcmalloc to prefer the mmap allocator to sbrk allocator

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.3
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL

      We don't currently set NDEBUG for our --dbg=off builds, instead relying on _DEBUG.

      The only standard mandated behavior for NDEBUG is that it alters the semantics of 'assert'. And we don't use bare asserts in the mongodb source.

      However, the code in third_party may interpret NDEBUG, and, in particular, tcmalloc cares.

      Please see https://github.com/mongodb/mongo/blob/cc506fc6a274b57ee31dac021cdecd5aee084d08/src/third_party/gperftools-2.0/src/system-alloc.cc#L80-L84

      The consequence is that kDebugMode becomes true, which is used:

      https://github.com/mongodb/mongo/blob/cc506fc6a274b57ee31dac021cdecd5aee084d08/src/third_party/gperftools-2.0/src/system-alloc.cc#L457-L464

      to determine whether to prefer the mmap or sbrk allocator.

      Since we don't define NDEBUG, tcmalloc ends up preferring the mmap allocator, which is not its intended production deployment configuration.

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

              Created:
              Updated:
              Resolved: