This is the bug report I sent to MS, in case anyone wants to play with this.
This is a Visual FoxPro bug about
FoxPro Version (pick one): 8.0 SP1
Reproduces (pick one): always
Hardware and Software Details:
Dell opteron 2.6 GHz Celeron
Windows 2000
Happens on other machines as well.
Other Development Environments? yes
If yes which? Visual Studio .net 2003
Steps to Reproduce:
1) First create a database, and put a table in it, put some records in it.
CREATE DATABASE ZOOT
CREATE TABLE ZOOT (Z1 C(10), Z2 C(10), CHANGE T )
INSERT INTO ZOOT (Z1) VALUES ('ZOOT')
2) Set record validation Rule - we want this procedure in the DBC to execute
when a record is changed:
setchange()
3) Create stored procedure in DBC called SetChange:
PROCEDURE setChange
TRY
IF glSetChange
REPLACE CHANGE WITH DATETIME()
ENDIF
CATCH
* WAIT WINDOW 'An error has occured'
ENDTRY
RETURN .T.
ENDPROC
4) Run this code:
USE ZOOT
SET STEP ON
REPLACE Z1 WITH 'NoZoot', Z2 WITH BadVarName
Notice that glSetChange is uninitialized. This is by design. Notice that
BadVarName is undefined. In order to reproduce this error, you need a two
part REPLACE, and the first one (Z1 WITH 'NoZoot') must be valid, and the
second one (Z2 WITH BadVarName) must be invalid IE have a runtime error such
as uninitialized variable or invalid table/field name, etc.
Observed Behavior:
I step through the code via the above SET STEP because if you dont,
sometimes VFP will just hard terminate, poof and it's gone. If you step
through it, when you get to this line:
TRY
IF glSetChange
You should get a c0000029.
It varies according to the code in SetChange, but it will consistently
crash. If I change the code slightly , I can get c0000005, c0000029. I also
get MS VC++ Runtime Library error, Buffer overrun detected error. The code I
posted above seems to consistently produce c0000029.
This, for example,
IF glSetChange .AND. 1 = 1
seems to produce a buffer overrun warning, other variations produce a
mismatched push/pop type of message.
Expected Behavior:
A trappable VFP error should be generated, not a hard crash.
Additional Information:
I can get a crash in VFP7 by using this code in SetChange:
PROCEDURE setChange
ON ERROR llZOOT = .T.
IF glSetChange
REPLACE CHANGE WITH DATETIME()
ENDIF
ON ERROR
RETURN .T.
ENDPROC
Since VFP7 does not support TRY/CATCH, I use traditional error trapping
instead.
In VFP9 the same process generates a c0000005 error.