Forum Stats

  • 3,855,690 Users
  • 2,264,543 Discussions
  • 7,906,138 Comments

Discussions

[VS2015] Debug assertion at all std::string related functions

I'm getting debug assertion(__acrt_first_block == header) when using any of the std::string related OCCI functions(SQLException::getMessage(), Statement::getString(), etc). The functions themselves do work so for example when using ::getMessage I get the message but get an assertion at the end of deallocator block. I'm using Visual Studio 2015 Enterprise with Oracle 12.1.0(vc12). "Release" build doesn't cause any problems and works as expected.

Answers

  • user11970611
    user11970611 Member Posts: 1 Blue Ribbon
    edited Jan 15, 2016 12:13PM

    I want to support your question. I have the same context except for VS because I use VS2013 Community.

    I tried two different platforms Win32 and X64 and the result is the same.

  • asy
    asy Member Posts: 285
    edited Jan 21, 2016 7:55AM

    I am using OCI, not OCCI. That makes me just guessing what your problems are. But I think it is clear.

    You cannot assume that a std::string is the same in debug and release versions, and you cannot assume that a std::string is the same across different stl versions. So you have to use the same std::string interpretation at both ends, in your software as well as in the OCCI library. And be aware that there is a Microsoft version of a STL, and there are others.

    Have a Look at: Using OCCI with Microsoft Visual C++ (see below). You have to link to two different versions of oraocci(d).dll, and you are forced to use the Microsoft version of stl.

    Using OCCI with Microsoft Visual C++
    The Oracle Database 11gR1 release includes OCCI libraries for developing applications with Microsoft Visual C++ version 8.0 (.NET 2005) Microsoft Visual C++ version 7.1 (.NET 2003). Microsoft Visual C++ version 7.0 is no longer supported.
    Microsoft Visual C++ version 7.1 libraries are installed in the following default locations:
         ORACLE_BASE\ORACLE_HOME\bin\oraocci11.dll
         ORACLE_BASE\ORACLE_HOME\oci\lib\msvc\oraocci11.lib
    Copies of these two files are also installed under the directory:
         ORACLE_BASE\ORACLE_HOME\oci\lib\msvc\vc71
    The Microsoft Visual C++ 8.0-specific version of the libraries is installed under:
         ORACLE_BASE\ORACLE_HOME\oci\lib\msvc\vc8
    Applications should link with the appropriate OCCI library. You must ensure that the corresponding DLL is located in the Windows system PATH.
    Applications that link to MSVCRTD.DLL, a debug version of Microsoft C-Runtime, /MDd compiler flag, should link with these specific OCCI libraries: oraocci11d.lib and oraocci11d.dll.
    

    Personally, I would advise to use OCI, not OCCI. If you can avoid std::string, you can avoid such problems. Even more, the OCI dll should be loaded dynamically, and all functions be called indirectly. That way, you can handle dll loading problems and different client versions.

This discussion has been closed.