[SERVER-11010] Building without NDEBUG defined causes tcmalloc to prefer the mmap allocator to sbrk allocator Created: 02/Oct/13  Updated: 11/Jul/16  Resolved: 03/Oct/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5.3

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Andrew Morrow (Inactive)
Resolution: Done 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   

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.



 Comments   
Comment by auto [ 03/Oct/13 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@10gen.com'}

Message: SERVER-11010 Use Append rather than AppendUnique to fix build breakage
Branch: master
https://github.com/mongodb/mongo/commit/adabaf90744d3e661622849e44b63f2395188703

Comment by auto [ 03/Oct/13 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@10gen.com'}

Message: SERVER-11010 For non-debug builds, build gperftools with NDEBUG to prefer the sbrk allocator
Branch: master
https://github.com/mongodb/mongo/commit/09778704b9d7f8fb8b0d1ab170e2cf502387b78b

Generated at Thu Feb 08 03:24:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.