Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC9.0 Win7 VS2010 Win2008-R2 , +
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 17-Feb-11 2:08am
Edited 17-Feb-11 2:30am
v2
Comments
Shilpi Boosar at 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 at 17-Feb-11 10:07am
   
Can you post a stack trace? This is almost always expected when asking a question like yours.
Debojyoti Majumder at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
v2
Comments
Debojyoti Majumder at 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 at 18-Feb-11 8:57am
   
Try running your application with the page heap enabled (just for the process in question).
Debojyoti Majumder at 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)

  Print Answers RSS
0 OriginalGriff 7,800
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 30 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100