Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I created my application in VC++ and I have to verify my it using AppVerifier.
When I am testing my application with AppVerifier the application crashes when I am closing the application window. I have debugged my application and from the stack trace I came to know it's crashing in the last called destructor, but that one doesn't have any code in it.
If anyone is observing similar problems please respond with a comment and anyone having some idea please help me finding a solution to this.

Thanks in advance!
Posted
Updated 17-Feb-11 1:30am
v2
Comments
ShilpiP 17-Feb-11 7:42am    
Did you free all your heap memory ?? Program may crash if you are not properly deallocate your memory that you initialize.
Stephen Hewitt 17-Feb-11 10:07am    
Can you post a stack trace? This is almost always expected when asking a question like yours.
Debojyoti Majumder 17-Feb-11 22:54pm    
Here is my stack trace
vrfcore.dll!000007fef03937ed()
[Frames below may be incorrect and/or missing, no symbols loaded for vrfcore.dll]
vrfcore.dll!000007fef03997d4()
ntdll.dll!0000000077103703()
vfbasics.dll!000007feefc566d2()
vfbasics.dll!000007feefc5818e()
vfbasics.dll!000007feefc57872()
ntdll.dll!0000000077048a8f()
ntdll.dll!00000000770459b2()
ntdll.dll!000000007707fe48()
comctl32.dll!000007fefd2c1a09()
comctl32.dll!000007fefd2c1a7b()
comctl32.dll!000007fefd2c83b1()
> mfc100d.dll!CComCtlWrapper::_ImageList_Destroy(_IMAGELIST * himl=0x000000001f6179d0) Line 230 + 0xd2 bytes C++
mfc100d.dll!AfxImageList_Destroy(_IMAGELIST * himl=0x000000001f6179d0) Line 40 + 0x22 bytes C++
mfc100d.dll!CImageList::DeleteImageList() Line 1399 C++
mfc100d.dll!CImageList::~CImageList() Line 1375 + 0xd bytes C++
WinDiag.exe!CMainFrame::~CMainFrame() Line 72 + 0x27 bytes C++
WinDiag.exe!CMainFrame::`scalar deleting destructor'() + 0x2c bytes C++
mfc100d.dll!CFrameWnd::PostNcDestroy() Line 264 + 0x31 bytes C++
mfc100d.dll!CWnd::OnNcDestroy() Line 890 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message=130, unsigned __int64 wParam=0, __int64 lParam=0, __int64 * pResult=0x000000000023e140) Line 2354 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message=130, unsigned __int64 wParam=0, __int64 lParam=0) Line 2067 + 0x2b bytes C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd=0x000000000bfde830, HWND__ * hWnd=0x0000000000eb02a0, unsigned int nMsg=130, unsigned __int64 wParam=0, __int64 lParam=0) Line 248 + 0x30 bytes C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd=0x0000000000eb02a0, unsigned int nMsg=130, unsigned __int64 wParam=0, __int64 lParam=0) Line 411 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd=0x0000000000eb02a0, unsigned int nMsg=130, unsigned __int64 wParam=0, __int64 lParam=0) Line 420 + 0x18 bytes C++
user32.dll!0000000076e2c3c1()
user32.dll!0000000076e2a01b()
user32.dll!0000000076e1f56e()
ntdll.dll!000000007707fdf5()
user32.dll!0000000076e1f5ba()
mfc100d.dll!CWnd::DestroyWindow() Line 1033 + 0xf bytes C++
mfc100d.dll!CDocument::OnCloseDocument() Line 857 C++
mfc100d.dll!CDocTemplate::CloseAllDocuments(int __formal=0) Line 433 C++
mfc100d.dll!CDocManager::CloseAllDocuments(int bEndSession=0) Line 666 C++
mfc100d.dll!CWinApp::CloseAllDocuments(int bEndSession=0) Line 102 C++
mfc100d.dll!CFrameWnd::OnClose() Line 880 C++
WinDiag.exe!CMainFrame::OnClose() Line 262 C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message=16, unsigned __int64 wParam=0, __int64 lParam=0, __int64 * pResult=0x000000000023ea30) Line 2354 C++
mfc100d.dll!CWnd::WindowProc(unsigned int message=16, unsigned __int64 wParam=0, __int64 lParam=0) Line 2067 + 0x2b bytes C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd=0x000000000bfde830, HWND__ * hWnd=0x0000000000eb02a0, unsigned int nMsg=16, unsigned __int64 wParam=0, __int64 lParam=0) Line 248 + 0x30 bytes C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd=0x0000000000eb02a0, unsigned int nMsg=16, unsigned __int64 wParam=0, __int64 lParam=0) Line 411 C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd=0x0000000000eb02a0, unsigned int nMsg=16, unsigned __int64 wParam=0, __int64 lParam=0) Line 420 + 0x18 bytes C++
user32.dll!0000000076e2c3c1()
user32.dll!0000000076e2a01b()
user32.dll!0000000076e2a061()
ntdll.dll!000000007707fdf5()
user32.dll!0000000076e2a08a()
user32.dll!0000000076e2a389()
user32.dll!0000000076e1e095()
user32.dll!0000000076e1e028()
user32.dll!0000000076e2c3c1()
user32.dll!0000000076e26484()
user32.dll!0000000076e52bdb()
mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg=274, unsigned __int64 wParam=61536, __int64 lParam=8847406) Line 1069 + 0x2f bytes C++
mfc100d.dll!CWnd::Default() Line 282 C++
mfc100d.dll!CWnd::OnSysCommand(unsigned int __formal=61536, unsigned int __formal=61536) Line 470 + 0x1c bytes C++
mfc100d.dll!CFrameWnd::OnSysCommand(unsigned in

The C++ compiler will add its own statements to the destructor to destruct any member variables that are a class type.

Consider this:
class A {
	public:
		A() { m_szMessage = new char[10]; }
		~A() { delete []m_szMessage; }
	private:
		char *m_szMessage;
};

class B {
	public:
		B() { /*A::A() is called here by the compiler*/ }
		~B() { /*A::~A() is called here by the compiler*/ }
	private:
		A m_clsA;
};


I suspect that you have a similar scenario where your stack trace was in B::~B().
If the destructor to A is called twice, or by some other means the memory of A is deleted twice then the 2nd time it is deleted it will crash.

There are a number of other reasons that a program may crash when deleting memory too.
When in debug mode the compiler will check the heap around the allocated memory, and if you write 11 characters into the buffer of size 10 above then this would cause the debugger to break.
 
Share this answer
 
Thanks for the stack trace. Also, the exception type generated is often of use. In addition, since you're using the application verifier look at the debugger output window as the verifier will tell you what the problem is (via debug strings). To me it looks like you're freeing an invalid image list or freeing one twice.
 
Share this answer
 
v2
Comments
Debojyoti Majumder 17-Feb-11 23:25pm    
Thanks... App-verifier telling it's caused because of heap.

I tried not to use CImageList in my project and commented them (made my application without Icons).

I got crash in some other point.
The reason is same... "Heaps".
Stephen Hewitt 18-Feb-11 8:57am    
Try running your application with the page heap enabled (just for the process in question).
Debojyoti Majumder 3-Mar-11 1:41am    
can you give any hint or link to do so??
It would be very helpful for me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900