Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
legacy-1.0.3
Description
At all this problem exist only if the compiled MongoDB Driver is used in a DLL Target. If the same files will be used in a DLL, than this particular problem does not occur!
In my real target the problem occur when using the Macro GENOID or mongo::BSONObjBuilder().genOID()... Since I did not found the reason for this problem in my DLL project I was guessing this problem is because the Mongo driver is used in a DLL not an executable.
Additional hint:
For me it is mandatory to use the MongoDB driver in a DLL, the older drivers (v2.4.x and 2.5.x worked fine, the 26compat driver was only tested a little, therefore I can not tell anything about this.
How to reproduce the problem:
1. I used Visual Studio 2010SP1 to generate the MongoDB driver and I used Boost 1.51 to create the driver. I used the followed scons call:
scons.py --prefix=E:\LibraryBuild\mongo-cxx-driver-legacy-1.0.3\mongoDriver --cpppath=E:\LibraryBuild\boost_1_51_0 --libpath=E:\LibraryBuild\boost_1_51_0\stage\x64\lib-boost --64 install --dynamic-windows --sharedclient --dbg=on
I created also the remeining possible driver versions as stated in the description:
scons $ARGS install
scons $ARGS install --dbg=on
scons $ARGS install --dynamic-windows --sharedclient
scons $ARGS install --dynamic-windows --sharedclient --dbg=on
2. I created a DLL and I exported a function using the followed code:
#include <WinSock2.h>
#include <Windows.h>
#include <cstdlib>
#include <iostream>
#include "mongo/client/dbclient.h" // for the driver
extern "C" __declspec(dllexport) void Test()
{ mongo::OID oid; oid.init(); // <-- Here occurs the problem std::string str=oid.toString(); }The exception occurs a oid.init(), in OID::init() the function setincrecment is called, in OID::Increment OID::Increment::next() the line is called, than in scoped_ptr.hpp in T* oparator->() the assert will be triggered because px is 0.