Using OCCT libraries application "Debug Assertion Failed" on Windows

I created small lib for file conversion using OCCT. I prepared two builds int Release and Debug configuration. Lib works ok in release configuration, but crashes at the end of process in debug mode. I tried official OCCT 7.5.0 binaries as well as my own builds (MSVC14 and MSVC15) with the same results. Error message is shown in snapshot attached. What may be a reason of this crash? The same code compiled on Linux works OK in both configurations.
I'm using this lib in other application and it is hard to work without debug builds.

Kirill Gavrilov's picture

Current description doesn't allow making a reproducer and some analysis.

However, MSVC has a general issue that may trigger in your particular case - Debug and Release C++ runtimes coming with MSVC are incompatible to each other. So that if your library is built in Debug mode and OCCT is built in Release mode, then memory corruptions may happen. This happens actually not exactly due compiler optimization flags, but due C++ runtime DLL choice (it is technically possible making a Release build with Debug CRT).

So, the first step is to check if Debug DLLs from OCCT are used with your Debug library (you may notice that there are no Debug libraries within official OCCT 7.5.0 binaries!).

There are some fragile tricks allowing to mix Debug/Release CRT in application, but in general this combination should be avoided. Structures like std::istream and FILE have different definitions in Debug/Release builds within MSVC CRT, which leads to crashes when passing object created by another CRT - and this is only one of examples of possible clashes. This is normally not an issue on Linux, because GCC and Glibc relies on smarter mechanisms to ensure binary compatibility with CRT.

Adam Wnek's picture

Thank you for your answer.
Sorry for my late reply.
My original thought, was similar, so I created my own MSVC14 builds (Release and Debug) configuration. Still had the same results. Maybe I wrongly linked other libraries building OCCT. I have to investigate this again.