Click here to Skip to main content
13,045,657 members (64,327 online)
Click here to Skip to main content
Add your own
alternative version


47 bookmarked
Posted 27 May 2000

Handle Application Crashes Better

, 2 Jun 2000
Rate this:
Please Sign up or sign in to vote.
A method of getting more details about application crashes.
<!-- Link to demo file download -->
  • Download demo project - 24 Kb
  • <!-- Article image -->

    Sample Image - DumpHandle.gif


    When dealing with application crashes, customers don't always send details of the crash when they report problems. They often don't realise they have to press the Details button, they dont tell you which version it is, or they might get Dr Watson dumps. Either way, you get either too much information, or not enough.

    Having seen Martin Ziacek's article "SEH and C++ Exceptions - catch all in one" article, this provided me with a method to get better application crash handling.


    Martin's article shows how to gain control after an Exception, what was needed was to present the information to the user. Firstly I added some code to traverse the stack in a backwards fashion, and collect all the adresses of all the calls.

    void SeTranslator(UINT nSeCode, _EXCEPTION_POINTERS* pExcPointers)
    	CSeException *se = new CSeException(nSeCode, pExcPointers);
    	**  Save the last 32 functions called
    	DWORD * sp = (DWORD *)(pExcPointers->ContextRecord->Ebp);
    	for(int i=0;i<32;i++)
    		if(!IsBadReadPtr(sp,sizeof(DWORD)) && *sp)
    			DWORD *np = (DWORD *)*sp;
    			se->m_StackTrace[i] = *(sp+1);
    			sp = np;
    			se->m_StackTrace[i] = 0;
    	throw se;

    This way, when the application regains control after the throw, the stack at the time of the crash is known.


    All that is needed now is to present the crash details to the user. This is done by deriving your application object from CDumpHandleApp instead of CWinApp. CDumpHandleApp does the rest. In the InitInstance you need to add a call to the base class CDumpHandleApp::InitInstance and to set the support email address.

    BOOL CDumpHandleDemoApp::InitInstance()
    	**  Initialize the dumper code
    		return FALSE;
    	m_strSupportEmail = "";


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Shane Hyde
    Web Developer
    Australia Australia
    No Biography provided

    You may also be interested in...


    Comments and Discussions

    Generalcan't use with Thread??? [modified] Pin
    Motorcure11-Aug-08 4:32
    memberMotorcure11-Aug-08 4:32 
    Generaldon't work with VS 2005 and SP 1 Pin
    FrameFever15-Jun-07 5:57
    memberFrameFever15-Jun-07 5:57 
    GeneralRe: Pin
    NonamedAuthor29-Aug-05 21:18
    memberNonamedAuthor29-Aug-05 21:18 
    QuestionHow to get debug info from DLL we have loaded Pin
    coolvcguy19-Dec-02 2:20
    susscoolvcguy19-Dec-02 2:20 
    GeneralGood, but.. Pin
    Mark Ivison24-Jul-00 23:45
    sussMark Ivison24-Jul-00 23:45 
    QuestionHow to interpret the stack dump Pin
    Michael Walz4-Jun-00 23:41
    sussMichael Walz4-Jun-00 23:41 
    AnswerRe: How to interpret the stack dump Pin
    Shane Hyde5-Jun-00 4:31
    sussShane Hyde5-Jun-00 4:31 
    GeneralRe: How to interpret the stack dump Pin
    Anonymous29-Jun-01 14:51
    memberAnonymous29-Jun-01 14:51 
    GeneralSmall bug Pin
    Shane Hyde31-May-00 5:00
    sussShane Hyde31-May-00 5:00 
    GeneralRe: Small bug Pin
    Matt J. Lee12-Jul-01 23:19
    memberMatt J. Lee12-Jul-01 23:19 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web01 | 2.8.170713.1 | Last Updated 3 Jun 2000
    Article Copyright 2000 by Shane Hyde
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid