Hey, Ive been working on a program for a while, and once in a while it will crash for an unknown reason. I checked the error log and it says exception 0xc0000005 which means i'm writing somewhere i shouldn't. What are some common causes of this? Also is there anyway to use the fault offset to see where the error is (maybe in assembly?)... the error log says:
Faulting application Monitor 4 vc++.exe, version 0.0.0.0, time stamp 0x4a3262ca, faulting module ntdll.dll, version 6.0.6001.18000, time stamp 0x4791a7a6, exception code 0xc0000005, fault offset 0x00068bc0, process id 0x1588, application start time 0x01c9ebe1b60ba13c.
this may not be a c++ question but the program is in c++, i saw somewhere that it can be caused by using strlen on a non-null ended char array... is there anything else i should look for?
i can not cause this error, it just "happens" sommetimes
thanks
If you don't want to post your code, then maybe a cut down version. But the quickest way to do it yourself is to compile with debug info on and then run and wait till it crashes. The backtrace will tell you what memory component has been corrupted. It may take a little to work out what has actually happened as another array may have over writen it. The debugger can help listing the symbol and memory addresses.
You can also try valgrind. http://valgrind.org. Which finds memory errors/leaks etc. [with a few false positives.] This is also very good at finding array boundary errors.
Typical things you will find are memory that is assigned but not deleted. Memory that is created with new but deleted with free() and vis-vera. Array over runs. e.g
hey, thanks for your response. Unfortounately i am developping for/on windows... however i did add a null byte to the end of a char* i was using strlen on. so far no crashes.. but they werent too common before
should i do the same when using <std::string>.length()?
block:
I really don't think that the problem is with string. Examining you code fragment, buffer2 obviously has size (you could test this with a std::cout<<"Length of buffer2 == "<<buffer2.length()<<std::endl;
You haven't done something horrible like have your own local version of string ?? and then the horrific using namespace std; that everyone seems to add has caused you some problems. Basically you are going to need to look at your debugger.
But Valgrind works only with Linux platforms and is not supporting detecting and localizing resource leaks such as memory, GDI and USER objects, handles.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.