[CXX-1961] WINDOWS | Release build, bad alloc exeption Created: 16/Mar/20  Updated: 27/Oct/23  Resolved: 16/Mar/20

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Max Max Assignee: Kevin Albertson
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-3558 Installation docs for Windows should ... Closed

 Description   

Hi everyone,
There's a little problem. I've written a program in order to connect to the mongodb cluster Atlas and changed some values.
Than I've installed the mongoc driver versioned 1.16.2 and the version of mongocxx driver from the master branch.
The commands for mongoc driver are:

cd cmake-build
cmake -G "Visual Studio 16 2019" \
    "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" \
    "-DCMAKE_PREFIX_PATH=C:\mongo-c-driver" \
    ..

"path-to-msbuild\msbuild.exe" ALL_BUILD.vcxproj  - debug
"path-to-msbuild\msbuild.exe" "/p:Configuration=RelWithDebInfo" ALL_BUILD.vcxproj - release
"path-to-msbuild\msbuild.exe" INSTALL.vcxproj

The commands for mongocxx driver are:

cmake .. \
     -G "Visual Studio 16 2019"           \
    -DBOOST_ROOT=C:\boost_1_60_0          \
    -DCMAKE_PREFIX_PATH=C:\mongo-c-driver       \
    -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver

"path-to-msbuild\msbuild.exe" ALL_BUILD.vcxproj
"path-to-msbuild\msbuild.exe" INSTALL.vcxproj

I've changed .vcxproj, in accordance with this instruction — "Compiling with MSVC"  http://mongocxx.org/mongocxx-v3/installation/
for DEBUG/RELEASE x64
My program has worked as it should, with debug versions of drivers, until the last version was released. After last release, it has started to catch an bad_alloc exception.
Maybe I did something wrong? Maybe I've used wrong VS version?
env:
cmake 3.17.0-rc3
VS 2019
mongoc driver 1.16.2
mongocxx driver from github master branch

regards, max



 Comments   
Comment by Kevin Albertson [ 16/Mar/20 ]

Glad to help!

Comment by Max Max [ 16/Mar/20 ]

Kevin, thank you so much. 
This commands help me.  

for mongoc and for mongocxx :

 

msbuild.exe /p:Configuration=Release ALL_BUILD.vcxproj
msbuild.exe /p:Configuration=Release INSTALL.vcxproj

regards, max

Comment by Kevin Albertson [ 16/Mar/20 ]

Hi mpano91@gmail.com,

I am not sure off-hand what would have changed in 1.16.2. But for a crash like that, it is likely the C++ driver, C driver, and your application may be linked to different forms of Windows runtime libraries. It may be helpful to inspect the output of dumpbin.exe to check that your application, the C driver, and C++ driver, all use the same C runtime. E.g. Using the native tools command prompt for libmongoc:

dumpbin.exe /DEPENDENTS libmongoc-1.0.dll

You may find that the installed libmongoc is linked to the debug runtime, whereas the C++ driver is linked to the release runtime.

The command:

"path-to-msbuild\msbuild.exe" INSTALL.vcxproj

Seems to default to the Debug configuration if an explicit configuration is not specified. You can make that explicit if you intend to install the release form:

msbuild.exe /p:Configuration=Release INSTALL.vcxproj

If that does not help, can you include additional information:

  • the error message you are seeing, and a stacktrace if possible
  • the output of dumpbin on libmongoc, libmongocxx, and your application

Best,
Kevin

Generated at Wed Feb 07 22:04:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.