Access violation on sqlite3_open API call - c++

I am writing a server application with sqlite3 and c++. My problem occurs in the following line: int connect = _sqlite3_open(database_sqlite_file, &db);
In the MSVC++ logs I get these notes:
Unhandled exception at 0x74ABCB49 in Fantasia_Database.exe: 0xC0000005: Access violation executing location 0x00000000.
Anyone know the source of this error, what am I doing wrong?

Related

Unhandled exception at 0x00000000772CA267 (ntdll.dll) in *****.exe : 0xC0000005: Access violation writing location 0xFFFFFCA800000000

I am getting this exception
Unhandled exception at 0x00000000772CA267 (ntdll.dll) in ******.exe: 0xC0000005: Access violation writing location 0xFFFFFCA800000000.
When I look into callstack I don't see my code in the stack but the below:
ntdll.dll!RtlFreeHeap() Unknown
kernel32.dll!HeapFree() Unknown
winhttp.dll!CAuthData::Clear(void) Unknown
winhttp.dll!HTTP_USER_REQUEST::_AdjustCredentialStates(unsigned short,int *) Unknown
winhttp.dll!HTTP_USER_REQUEST::_ResponseProcessingLoop(class PENDING_API_CALL *) Unknown
winhttp.dll!HTTP_USER_REQUEST::OnRecvResponse(unsigned long) Unknown
winhttp.dll!WEBIO_REQUEST::OnIoComplete(unsigned long,unsigned __int64,class HTTP_ASYNC_OVERLAPPED *) Unknown
winhttp.dll!HTTP_THREAD_POOL::_WorkItemCallback(void) Unknown
ntdll.dll!TppWorkpExecuteCallback() Unknown
ntdll.dll!TppWorkerThread() Unknown
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown
We use SOAP req/res. But we have updated couple of req/res to REST not we use json req/res. After this change we get the above problem. Sometimes everything works fine You could say failure is 50% times.
Found the solution for this problem. Actually before this call there was bufferoverflow which was corrupting my heap. Fixing the bufferoverflow solved my problem.

OCCI resultset getString() method returning nullpointer error

I'm getting the below error when trying to fetch a string value from a column in the current row ( rs->getString(2) ):
Unhandled exception at 0x61d4336f (msvcp100d.dll) in OCCITest.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff.
For example, I'm using rs->getInt(1) to fetch the ID of the current row, and it works perfectly. (although I still got the above error when I tried to fetch it as a string)
The values in the database are varchar2 type, so I guess it should be returned as a string value. Anyone has any idea what could be the problem?
-Win10 64-bit
-Visual studio 2010
-Oracle db 11.2.0.2.0 64-bit
-Oracle instant client 64-bit
-building a 64-bit application
to see other people this question with answer:
as you say:
you can use oraocci11.lib instead of oraocci11d.lib,

Strange crash with exceptions

When debugging a C++ program in VS 2013, I get a crash (technically a "breakpoint") in an exception handler (catch block) after an exception is thrown. The following is from the Output window after it happens:
First-chance exception at 0x75E54878 in Program.exe: Microsoft C++ exception: _com_error at memory location 0x00C6EE24.
First-chance exception at 0x75E54878 in Program.exe: Microsoft C++ exception: ComException at memory location 0x00C6EF04.
First-chance exception at 0x75E54878 in Program.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
HEAP[Program.exe]: HEAP: Free Heap block 00FAB5A8 modified at 00FAB5D4 after it was freed
Program.exe has triggered a breakpoint.
I tweaked the code to find the cause and got it to the point that it does something as simple as displaying a message box. Something like:
try
{
...
}
catch (const Exception&)
{
::MessageBox(NULL, L"Error", L"Error", 0); // <-- Crash happens here,
// BEFORE the message box is displayed
}
The message from the Output window suggests that I'm trying to write to freed/invalid memory, but as you can see from this code snippet, that's not the case - I'm not even using variables at the time the crash happens.
Another strange thing is that, after the crash, the Call Stack window shows frames that were already unwound due to the exception, as if the call stack got "rebuilt".
Any ideas what's wrong?

log4cpp - Unhandled exception and access violation

Here is some example code I read from some tutorial:
int main(int argc, char* argv[])
{
log4cpp::OstreamAppender* osAppender = new log4cpp::OstreamAppender("osAppender", &cout);
osAppender->setLayout(new log4cpp::BasicLayout());
log4cpp::Category& root = log4cpp::Category::getRoot();
root.addAppender(osAppender);
root.setPriority(log4cpp::Priority::DEBUG);
root.error("Hello log4cpp in a Error Message!");
root.warn("Hello log4cpp in a Warning Message!");
log4cpp::Category::shutdown();
getchar();
return 0;
}
Error report:
Unhandled exception at 0x76fe15de of log4cpp_Test.exe: 0xC0000005: Access violation wile reading 0x00000024
What might have caused the error ?
The code which you have posted is ok. It is compiled and run well.
Are you sure that you have no additional code beside that posted one? The problem might be caused by just few additional lines.
It looks like somewhere NULL pointer is dereferenced, which causes the access violation.
I think you run into this bug ... and it is from 2008.

std::string crashing while iterating on mySQL connector query results

I'm trying to get a std::string from my database using mysql connexion
Here is the simple code:
sql::Statement *stmt = con->createStatement();
sql::ResultSet *res = stmt->executeQuery("SELECT * FROM test.new_table");
while (res->next()) {
std::string somestring = res->getString("idnew_table");
} //crashes here
delete res;
delete stmt;
So, the executeQuery is fine, I enter the loop, and if I break, the expected results are in somestring. After the somestring declaration, I step foward to the end of the loop, and it crashes before the next iteration!
Here is the call stack:
> msvcp100d.dll!std::_Lockit::_Lockit(int kind) Line 64 + 0x14 bytes C++
msvcp100d.dll!std::_Container_base12::_Orphan_all() Line 200 C++
CM.dll!std::_String_val<char,std::allocator<char> >::~_String_val<char,std::allocator<char> >() Line 478 + 0xb bytes C++
CM.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >() Line 755 + 0xf bytes C++
CM.dll!DAL::GetInfo() Line 45 + 0xc bytes C++
Output:
First-chance exception at 0x1038ad4a (msvcp100d.dll) in CMLauncher.exe: 0xC0000005: Access violation reading location 0xccccccd0.
Unhandled exception at 0x76f615de in CMLauncher.exe: 0xC0000005: Access violation reading location 0xccccccd0.
First-chance exception at 0x76f5016e in CMLauncher.exe: 0x00000000: The operation completed successfully.
Unhandled exception at 0x76f615de in CMLauncher.exe: 0x00000000: The operation completed successfully.
So it looks like I have some uninitialized memory somewhere in the C++ runtime lib...
It look like it's crashing in the std::string destructor, which kind of makes sense because it crashes when the scope of the string is done...
My best guess is that libmysql is using an older version of the C++ runtime (say msvcp90d.dll) and that it's clashing with the new one... does that even make sense?
I'm under windows 7, using mySQL Server 5.5, VS2010 Pro. all in 32bits. thx! I'll be happy to post any mroe information that is needed.
Edit: Before anyone else reads DumbCoders comment:
MySQL Connector example
The documentation specifies that both the statement and the resultSet have to be deleted.
This problem seems just like yours here.