Analysing a simple crash

This tutorial demonstrates launching the sample application, crashing the application and using Bug Validator to identify the location and cause of the crash.

We will demonstrate this with MFC and without MFC to show the benefits (clearer execution trace) and deficits (missing execution trace data) of tracing with MFC and without MFC.

Simple Crash with MFC

This tutorial analyses a simple NULL pointer dereference crash.

The tutorial is performed with MFC code instrumented so that MFC message processing and pointer validation calls are part of the application trace.

  1. Open the settings dialog by clicking the tools icon on the toolbar.
    Bug Validator Toolbar Settings
  2. The Settings Dialog is displayed. Select the Hook Insertion tab.
    Bug Validator Settings Hook Insertion Simple Crash
  3. Select the Use general DLL hook settings checkbox in the section marked DLL Hook Insertion, then select the first three checkboxes underneath it. The image shows that the MFC, CRT and STL DLLs have been selected to ensure these DLLs are instrumented.
  4. Click OK to accept the settings.
  5. Launch the sample application. Click on the launch icon on the toolbar.
    Bug Validator Toolbar Launch
  6. The Launch application wizard is displayed.
    Bug Validator Launch Wizard, Page 1
  7. Select the sample application nativeExample.exe using the Browse… button.
  8. Click the Next button to move to the 2nd page of the wizard.
    Bug Validator Launch Wizard, Page 2
  9. Leave the settings as the default settings.
  10. Click the Next button to move to the 3rd page of the wizard.
    Bug Validator Launch Wizard, Page 3
  11. Click the Start Application button to launch the application.
  12. The nativeExample.exe application is started.
    Bug Validator native example application
  13. Wait for the instrumentation of the application to complete.
  14. On the Bug Validator Execution History tab, click the Refresh button. The display will refresh.
    Notice that most of the display is MFC message processing. It’s hard to see what’s happening for all the MFC message processing.
    Bug Validator Simple Crash with MFC message processing
  15. On the nativeExample Crashes menu, choose Crash Write NULL Pointer. This will execute the code shown below, which dereferences a NULL pointer, causing an “Access Violation Exception”
    	// test of dereferencing a NULL pointer
    
    	DWORD	*dwPtr;
    
    	dwPtr = NULL;
    
    	// the next line will crash
    
    	*dwPtr = 0;
    
  16. The exception will cause the following dialog box to be displayed by the operating system:
    Windows NT, Windows 2000
    Exception on Windows NT, 2000
    Windows XP
    Exception Windows XP
    Do not click any of the buttons on the dialog.
  17. You will also see the Bug Validator crash detected dialog.
    Bug Validator crash detected dialog
  18. On the Bug Validator Execution History tab, click the Refresh button. The display will refresh.
    You can now click the buttons on the Windows Exception Dialog as you desire (to dismiss the application or enter the debugger etc).
  19. Scroll to the bottom of the display. The image will look similar to the image shown below.
    Bug Validator native application simple crash with MFC
    As you can see in the image above, the exception has been caught in the unhandled exception filter. The yellow item indicates where an exception was encountered.

    Scroll up from the bottom of the list until you get to the yellow item, which indicates an exception.

    You can see details about the exception shown above the source code.
    Bug Validator native application simple crash with MFC

Simple Crash without MFC

This tutorial analyses a simple NULL pointer dereference crash.

The tutorial is performed without MFC code instrumented, so that MFC message processing and pointer validation calls are not part of the application trace.

This makes the trace simpler to understand, with the penalty that if the crash is within MFC, you cannot see the trace to the location of the crash.

  1. Open the settings dialog by clicking the tools icon on the toolbar.
    Bug Validator Toolbar Settings
  2. The Settings Dialog is displayed. Select the Hook Insertion tab.
    Bug Validator Settings Hook Insertion Exclude MFC, CRT, STL
  3. Select the Use general DLL hook settings checkbox in the section marked DLL Hook Insertion, then deselect the four check boxes underneath it. The image shows that the MFC, CRT, STL and system DLLs have been marked to be ignored (deselected). Click OK to accept the settings.
  4. Launch the sample application. Click on the relaunch icon on the toolbar.
    Bug Validator Toolbar Relaunch
  5. The nativeExample.exe application is started.
    Bug Validator native example application
  6. Wait for the instrumentation of the application to complete.
  7. On the nativeExample Crashes menu, choose Crash Write NULL Pointer.
  8. The exception dialog is displayed by the operating system. Do not click any of the buttons on the dialog.
  9. On the Bug Validator Execution History tab, click the Refresh button. The display will refresh. You can now click the buttons on the exception dialog as you desire (to dismiss the application or enter the debugger etc).
  10. Scroll to the bottom of the display. The image will look similar to the image shown below.
    Bug Validator Simple Crash without MFC
    Notice how the flow of the application is easier to follow without the MFC message loop processing filling up the display.
  11. The crash location is the second to last line in the scrolled list.

    The last line is the statement that caused the crash.

Fully functional, free for 30 days