Intentionally crash your program


When developing the Watson error reporting features (see Dr. Watson: Please send in your error report, and What is a C0000005 crash?, What was Dr. Watson’s original name?)) it was useful to cause a crash intentionally


 


In VFP we have a simple way to crash intentionally.


Try executing this: SYS(1079)


 


A MessageBox comes up saying “Cause an intentional crash for test purposes” with an OK and Cancel button. If you cancel, nothing happens. If you choose OK, then code like this gets executed:


 


char *cp=0; // declare a pointer to a char initialized to point to 0


*cp = 0;    // Put a value of 0 into address 0


 


which causes an Access Violation Exception, simulating an error occurring in an application.


 


This will typically cause a Dr. Watson dialog to appear.


 


If you execute SYS(1079) in your application code somewhere (or somehow cause an exception), then the VFP call stack also gets added into an error log and shown in a MessageBox.


 


 


foo(5)


PROCEDURE foo(n)


          IF n = 1


                   SYS(1079)


          ELSE


                   foo(n-1)


          ENDIF


RETURN


 


 


Fatal error: Exception code=C0000005 @ 11/16/05 04:14:29 PM. Error log file: D:\Fox90\VFP9err.log


 


            Called from –  foo line 46  {d:\fox90\test\tt.prg d:\fox90\test\tt.fxp}


 


            Called from –  foo line 48  {d:\fox90\test\tt.prg d:\fox90\test\tt.fxp}


 


            Called from –  foo line 48  {d:\fox90\test\tt.prg d:\fox90\test\tt.fxp}


 


            Called from –  foo line 48  {d:\fox90\test\tt.prg d:\fox90\test\tt.fxp}


 


            Called from –  foo line 48  {d:\fox90\test\tt.prg d:\fox90\test\tt.fxp}


 


            Called from –  tt line 43  {d:\fox90\test\tt.prg d:\fox90\test\tt.fxp}


 


I believe this VFP call stack dump is very useful for developers to identify the actual line of VFP code that caused the crash, allowing the user to possibly come up with a workaround. Has this call stack dump been useful to anybody? 

Comments (8)

  1. In VFP 8 (before the service pack) we discovered a weird error: If we had a combobox on a page in a pageframe and the pageframe had 7 tabs then we would get the C00005 exception when the page that had the combobox became activated. The service pack fixed this (as a work around we added a disabled tab to the pageframe). I think the combobox had to be a certain style (I’m trying hard to remember the details).

    The call stack info from the crash was exceptionally useful in narrowing down what was causing the exception. And helped us to report to the Fox Team how to easily reproduce the error (which they fixed with a service pack).

    Thanks!

  2. Rick Schummer says:

    My error handler captures the call stack so I can fix problems in my program. When a C5 occurs we do not have this opportunity via the error handler to capture it so it is extremely helpful when VFP can display and capture this information internally. I also appreciate how this informtion is being logged in the vfp9err.log file found in the VFP HOME() directory. Thanks.

  3. Like Rick, I’ve found it very helpful. Glad you guys made it so!

  4. fdgdg says:

    how? <8-(

  5. A customer asks: I read your article "Intentionally crash your program". I have some questions that I

  6. Olgunka-so says:

    <a href= http://index4.oloire.com >mouth jewellery</a> <a href= http://index5.oloire.com >bass pro shops ads</a> <a href= http://index1.oloire.com >fundimant behavior assesiment</a> <a href= http://index2.oloire.com >carrie underwood hates gays</a> <a href= http://index3.oloire.com >alta vista nude photo</a>

  7. Olgunka-so says:

    <a href= http://index4.oloire.com >mouth jewellery</a> <a href= http://index5.oloire.com >bass pro shops ads</a> <a href= http://index1.oloire.com >fundimant behavior assesiment</a> <a href= http://index2.oloire.com >carrie underwood hates gays</a> <a href= http://index3.oloire.com >alta vista nude photo</a>

  8. John McDonald says:

    Here’s a question for you.  I created a program that uses ShipRush SDK (a program to create Fedex Labels) and whenever I run the program the .exe program errors out with a Fatal error: Exception code=C0000005 (which is the ShipRush component).

    Anyways, the program itself runs fine, except when it tries to close I get the error.  

    Is there a way to disable the error message altogether.  I can’t find anywhere that ignores the fatal crash warning.  

    Thanks in advance.