Access violation in mlock
I have a console application (written using MS VS2010 SP1). No MFC, no ATL, just standard library. In debug build everything works Ok. But in release build there is an access violation: "First-chance exception at 0x77b0206e in Mapp.exe: 0xC0000005: Access violation reading location 0x002cef58."
If I run app from MS VS (even release mode), everything works Ok and I can't find out what is going on. I've tried to use just-in-time debugging and I received call stack:
ntdll.dll!77b020cb()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
Mapp.exe!_unlock(int locknum=72090689) Line 375 C
04320069()
It happend when app is shutting down and object destruction proceeds: there is one line like 'delete ptr' which cause an exception. But I several times check that code and found nothing. I've tried to use CRT debug functions (memory leaks diagnostic, custom memory allocation hooks etc) and no results. Also I find out, that problem is solved when use the debug version of CRT (use Multi-threaded Debug (/MTd) in release configuration). One more thing: when I perform some minor changes to the code (e.g. write a line of debug code) a call stack is changing and every time it is totally different. for example:
ntdll.dll!77b0206e()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
Mapp.exe!_unlock_fhandle(int fh=72090689) Line 491 C
04320069()
and the another one
ntdll.dll!77b0206e()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!77b0201f()
kernel32.dll!768cf1cc()
Mapp.exe!free(void * pBlock=0x024950f0) Line 51 C
Mapp.exe!CGISMapLineShape::~CGISMapLineShape() Line 20 + 0x13 bytes C++
Mapp.exe!CGISMapPolygonShape::`scalar deleting destructor'() + 0开发者_StackOverflow社区x13 bytes C++
Mapp.exe!CGISMapMultyPolygonShape::~CGISMapMultyPolygonShape() Line 9 C++
Mapp.exe!CGISMapMultyPolygonShape::`scalar deleting destructor'() + 0xc bytes C++
Mapp.exe!CGISMapShapeCollection::Clear() Line 307 C++
I understand that there are some bugs in fpplication code, but question is have can I find it Question
In release builds the memory handling is much different from debug builds. This error normally happen when you try to access an already deleted object. The callstack is crap if you don't load the symbols.
Finnaly I've cought it! It was several bugs and all of them - index out of range in array manipulation.
Thanks all for help!
精彩评论