Visual Studio 2015 Oracle exception debug assertion

Jan 7, 2016 at 7:38pm
I'm using Visual Studio 2015 Enterprise with Oracle 12.1.0. Here's the code causing assertion:
1
2
3
4
5
6
7
8
try
{
    // ..
}catch(oracle::occi::SQLException &e)
{
    std::cout << "Error code: " << e.getErrorCode() << std::endl;
    std::cout << "Error message: " << e.getMessage() << std::endl;   // Most likely here 
}


Debug assertion: __acrt_first_block == header
I'm assuming it has something to do with std::string being allocated by dll and deallocated by application but I'm not sure. Also I got no idea on how to fix it.
Jan 8, 2016 at 12:11pm
It has probable to do with the reference

catch(oracle::occi::SQLException &e)


I rarly use exception, but I would guess that the exception is no longer valid at that point. Try changing it to

catch(const oracle::occi::SQLException &e)
Jan 8, 2016 at 12:32pm
Thanks for the reply. That didn't work sadly. ::getMessage returns the error string as expected but crashes at deallocator.
Jan 8, 2016 at 2:07pm
You could try
1
2
3
4
5
catch(oracle::occi::SQLException &e)
{
    std::cout << "Error code: " << e.getErrorCode() << std::endl;
    std::cout << "Error message: " << e.what() << std::endl;   // Most likely here 
}
Jan 8, 2016 at 3:13pm
@Thomas1965 Wow thank you very much that did the trick.

Although there're still some issues. For example if I want to use ResultSet::getString(..) I'll probably still get the error. How would I go about fixing that?
Last edited on Jan 8, 2016 at 3:16pm
Jan 8, 2016 at 4:59pm
Glad that it worked.

What did the error actually say?

I guess you need to fix the error first.
Jan 8, 2016 at 7:03pm
It says "Debug assertion failed" with __acrt_first_block == header. Breakpoint is at the end of void _Deallocate(void * _Ptr, size_t _Count, size_t _Sz); function in xmemory0 where it calls ::operator delete(_Ptr);
Jan 8, 2016 at 9:23pm
It says "Debug assertion failed" with __acrt_first_block == header. Breakpoint is at the end of void _Deallocate(void * _Ptr, size_t _Count, size_t _Sz); function in xmemory0 where it calls ::operator delete(_Ptr);


Sorry I was not clear enough. I ment the msg in e.what(). Could you maybe post some code between the try and catch block? My guess is that there is some error before which actually leads to the exception thrown.
Jan 8, 2016 at 9:30pm
Oh database connection was failing so that was the reason of exception. Overall library works as expected it's just std::string related functions. They work but crash at deallocation.
Jan 8, 2016 at 11:57pm
I agree with PaulMcKenzie in your SO post http://stackoverflow.com/questions/34662466/oracle-exception-getmessage-causing-debug-assertion

It doesn't look like occi supports VS 2015 yet.

Jan 9, 2016 at 12:48am
I guess I'll have to keep using vc12 until they release vc14 version then..
Jan 9, 2016 at 1:12am
Maybe give this a try http://www.oracle.com/technetwork/developer-tools/visual-studio/overview/index-097110.html
it says it supports 2015.

EDIT: Actually after a closer look, it seems it's .Net only.
Last edited on Jan 9, 2016 at 1:16am
Feb 3, 2016 at 10:32am
OCCI 12cR1 is supported with VS2010, VS2012 and VS2013. Not with VS2015. Please see https://docs.oracle.com/database/121/NTCLI/pre_install.htm#NTCLI1252
Topic archived. No new replies allowed.