[SERVER-5348] Redefinition of macros while using the C++ driver makes it unusable with larger application code Created: 21/Mar/12  Updated: 05/Nov/15  Resolved: 03/Apr/12

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: None
Fix Version/s: 2.0.5, 2.1.1

Type: Bug Priority: Critical - P2
Reporter: Pedro Larroy Assignee: Eric Milkie
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

5d3433eb31a58a4fcd242f8a0437819f63df723e


Issue Links:
Related
related to SERVER-14889 report out of memory error when mallo... Closed
is related to SERVER-1042 mongo c++ headers have a #define for ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

when including the C++ driver, some important system calls and macros like 'assert' and 'malloc' get redefined ant not defined back into the original state. Makes using the C++ driver unusable as part of a larger application.

Will patches to fix this behaviour be accepted?

  1. 1 "/home/piotr/devel/mmcc_mongodb/3rd-party/mongodb/src/mongo/client/../util/allocator.h" 1
  2. 18 "/home/piotr/devel/mmcc_mongodb/3rd-party/mongodb/src/mongo/client/../util/allocator.h"

namespace mongo {

inline void * ourmalloc(size_t size)

{ void *x = malloc(size); if ( x == 0 ) dbexit( EXIT_OOM_MALLOC , "malloc fails"); return x; }

inline void * ourrealloc(void *ptr, size_t size)

{ void *x = realloc(ptr, size); if ( x == 0 ) dbexit( EXIT_OOM_REALLOC , "realloc fails"); return x; }

#define MONGO_malloc mongo::ourmalloc
#define malloc MONGO_malloc



 Comments   
Comment by auto [ 18/Apr/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 backport C++ driver macro redefinition isolation
Branch: v2.0
https://github.com/mongodb/mongo/commit/41be3168d42f058cdda271c7aa077002d3071256

Comment by auto [ 18/Apr/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 fine tune gcc version
Branch: master
https://github.com/mongodb/mongo/commit/23d3ac6904b62a84814e75ea405c7b7626b69eac

Comment by auto [ 18/Apr/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 fix dbtest failure on old compilers, take 2
Branch: master
https://github.com/mongodb/mongo/commit/8a0836beb86b21fa7deaf60776fb1269be0906a2

Comment by auto [ 18/Apr/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 fix dbtest failure on old compilers
Branch: master
https://github.com/mongodb/mongo/commit/b17c562f428af2f5301e987c43d379fe3de41f15

Comment by auto [ 18/Apr/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 better macro handling; added more tests
Branch: master
https://github.com/mongodb/mongo/commit/1fd8c6cb530c0564a58de4ab4b03dcd62f328b26

Comment by Eric Milkie [ 03/Apr/12 ]

C RTL functions like 'assert' and 'malloc' are no longer redefined by the C++ driver headers. All C++ driver use has been consolidated into one master header, dbclient.h. No other headers need be included.

Comment by auto [ 02/Apr/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 fix v8 build for new header layout
Branch: master
https://github.com/mongodb/mongo/commit/9f65f192302a4d35bae633cc5e46b400fd4d714e

Comment by auto [ 02/Apr/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 make dbclient.h the main C++ driver include file

This change fixes some #defines of common C functions so that their
definitions do not leak into consumer code.
I also had to change Labeler SIZE because it conflicts with Windows
SIZE.
pch.h is on its way out, but for now it's hanging around.
Branch: master
https://github.com/mongodb/mongo/commit/45f30389a9128fe2216371cabbe8426b634d68e9

Comment by auto [ 23/Mar/12 ]

Author:

{u'login': u'larroy', u'name': u'Pedro Larroy', u'email': u'pedro.larroy@gmail.com'}

Message: SERVER-5348: fix wrong usage of BOOST_CHECK_EXCEPTION macro BOOST_CHECK_EXCEPTION is to be used only with the boost unit test framework, not as a general tool to catch exceptions.

Signed-off-by: Eric Milkie <milkie@10gen.com>
Branch: master
https://github.com/mongodb/mongo/commit/31c48fa6bd479fb7d4ef34351097597f2c1c9665

Comment by Pedro Larroy [ 23/Mar/12 ]

Created a new pull request: https://github.com/mongodb/mongo/pull/193

Comment by Pedro Larroy [ 23/Mar/12 ]

The change is done, can you please integrate it?
Thanks.

Comment by Eric Milkie [ 22/Mar/12 ]

I commented on your pull request. I can merge it in after you make the suggested change.

Comment by auto [ 22/Mar/12 ]

Author:

{u'login': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-5348 don't override malloc/realloc for C++ driver consumers
Branch: master
https://github.com/mongodb/mongo/commit/2992cda30157bd4a4562608bcbca47fd774b285f

Comment by Pedro Larroy [ 22/Mar/12 ]

Done.

Comment by Eric Milkie [ 21/Mar/12 ]

Hi Pedro,
Thanks for submitting the pull request. I'll take a look at it tomorrow.
In the meantime, if you haven't already, could you please sign the contributor agreement at http://www.10gen.com/contributor

Comment by Pedro Larroy [ 21/Mar/12 ]

Created pull request:

https://github.com/mongodb/mongo/pull/191

Please apply.

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