Reputation: 33
I'm developing an application in VC++ that links to a static lib of utility functions and also makes use of the mongocxx v3.6.5#2 driver. I'm getting:
Debug Assertion Failed!
Program: E:\MyApp\x64\Debug\MyApp.exe File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp Line: 996
Expression: __acrt_first_block == header
when a std:string object returned from a bson object goes out of scope. I've carefully compared the compiler / linker settings for my app project and my library project to make sure they are compatible. I suspect that mongocxx build is somehow incompatible.
Here's the simplest code sample that exhibits the problem. The assertion failure occurs when the function returns.
// OID to_string test
#include <bsoncxx/oid.hpp>
void Oid_str(void)
{
bsoncxx::oid idAlarmId;
std::string sAlarmId = idAlarmId.to_string();
}
The mongocxx driver was installed with vcpkg which lists it as: mongo-cxx-driver:x64-windows 3.6.5#2 MongoDB C++ Driver.
Some project properties on my projects that seem relevant:
Platform Toolset: Visual Studio 2019 (v142)
C++ Language Standard: ISO C++14
C Language Standard: Legacy MSVC
vcpkg Triplet x64-windows
Code Generation:
Enable SEH Exceptions (/EHa)
Runtime: Multi-threaded Debug (/MTd)
I'm hoping someone can point me in the right direction to solve this
Upvotes: 0
Views: 94
Reputation: 33
Changing the Runtime Library to Multi-Threaded Debug Dll (/MDd) on my app- and lib projects seems to do the trick. While My app is still linking to my own static LIB, /MDd makes everything run smoothly under the debugger
Upvotes: 0