jirentabu / crashrpt

Automatically exported from code.google.com/p/crashrpt
0 stars 0 forks source link

Some MFC exceptions are not handled #198

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
 I found that certain MFC exceptions were not being trapped by crashreport.  Here’s some code to put into CMFCDemotApp::OnAppAbout() that will show the issue:

// App command to run the dialog
void CMFCDemoApp::OnAppAbout()
{
// Create an mfc array with 10 doubles, for example.
typedef CArray<double,double> CDoubleArray;
CDoubleArray dArray;
dArray.SetSize(10);
for(int i=0; i<10; i++)
  dArray.SetAt(i, i*3.14);

// Read off the end of the array
// This with throw an mfc exception when i==10
// The exception will not be trapped by CrashRpt.
double sum=0.0;
for(int i=0; i<100; i++)
  sum += dArray.GetAt(i);

CAboutDlg aboutDlg;
aboutDlg.DoModal();
}

The standard MFCDemo with CrashRpt doesn’t trap this exception.  MFC reports 
"Encountered an Improper Argument".  After researching this a bit, I found an 
approach that makes it work with CrashRpt.  The key is to add an override to 
CWinApp::ProcessWndProcException() in the application class.  This method is 
called by MFC when there’s an unhandled MFC exception.  Here’s my override 
for MFCDemo:

LRESULT CMFCDemoApp::ProcessWndProcException(CException* e, const MSG* pMsg)
{
// This is where we land with some MFC exceptions.
// If we needed to show a message or something, we could do that here.
// However, in most cases, we just want to cause MFC to throw the exception out 
to CrashRpt.

// Make MFC throw (and not catch) this exception so that CrashRpt can catch it.
THROW_LAST();

return 0;
//return CWinApp::ProcessWndProcException(e, pMsg);
}

With this override in place, the MFC exception eventually finds its way into 
the CrashRpt handlers and we proceed with the crash report generation.

Original issue reported on code.google.com by zexspect...@gmail.com on 17 Apr 2013 at 2:13

GoogleCodeExporter commented 9 years ago

Original comment by zexspect...@gmail.com on 17 Apr 2013 at 2:17

GoogleCodeExporter commented 9 years ago
Issue 197 has been merged into this issue.

Original comment by zexspect...@gmail.com on 17 Apr 2013 at 2:19

GoogleCodeExporter commented 9 years ago
Added changes to documentation to take this into account.

Original comment by zexspect...@gmail.com on 20 Apr 2013 at 3:43

GoogleCodeExporter commented 9 years ago
Can you please guide me how to get crash report for any kind of exceptions.
i did the steps which is mentioned in documentation. 
still i m unable to track exceptions.

can you please guide me to catch dll exceptions.

First-chance exception at 0x000007f785ee8497 in MYdemo.exe: 0xC0000005: Access 
violation writing location 0x0000000000000000.

how to handle this case with crashrpt?

Original comment by srinivasmca25 on 19 Dec 2013 at 10:12

Attachments: