次の方法で共有


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

  • Anonymous
    November 16, 2005
    The comment has been removed

  • Anonymous
    November 17, 2005
    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.

  • Anonymous
    November 17, 2005
    Like Rick, I've found it very helpful. Glad you guys made it so!

  • Anonymous
    March 27, 2006
    how? <8-(

  • Anonymous
    December 07, 2006
    A customer asks: I read your article "Intentionally crash your program". I have some questions that I

  • Anonymous
    July 12, 2008
    <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>

  • Anonymous
    July 12, 2008
    <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>

  • Anonymous
    August 20, 2009
    The comment has been removed