Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RESTORE FROM MEMO causing invalid page faults
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
RESTORE FROM MEMO causing invalid page faults
Miscellaneous
Thread ID:
00117609
Message ID:
00117609
Views:
74
We have a VERY large application (over 900 files in the project) which is causing invalid page fault illegal operation errors at many of our sites. We've been able to run some coverage logs and determine that the most frequent occurrence is on a line of code that says:

RESTORE FROM MEMO triggers.memvars ADDITIVE

I created a small test form yesterday afternoon that did SAVE TO MEMO then RESTORE FROM MEMO in a loop and ran at least 500,000 iterations. It never crashed. I expected that it wouldn't be that easy. Here's the relevent portion of code:

lnCount = 50000
FOR I = 1 TO lnCount
IF ThisForm.lAbort
EXIT
ENDIF
CREATE CURSOR triggers (memvars M)
APPEND BLANK
redef_One = 1
redef_One2 = 1
redef_One3 = "wilma"
redef_One4 = 1
redef_One5 = 1
redef_One6 = "fred"
redef_One7 = 1
redef_One8 = 1
redef_One9 = 1
redef_One10 = 1
SAVE TO MEMO memvars ALL LIKE redef_*
RELEASE ALL LIKE redef_*
GO TOP
GO BOTTOM
GO 1
* either this next line or the next occurrence can crash
RESTORE FROM MEMO memvars ADDITIVE

APPEND BLANK
redef_One = 1
redef_One2 = 1
redef_One3 = "wilma"
redef_One4 = 1
redef_One5 = 1
redef_One6 = "fred"
redef_One7 = 1
redef_One8 = 1
redef_One9 = 1
redef_One10 = 1
SAVE TO MEMO memvars ALL LIKE redef_*
RELEASE ALL LIKE redef_*
GO TOP
GO BOTTOM
GO 2
* either this next line or the previous occurrence can crash
RESTORE FROM MEMO memvars ADDITIVE
USE IN triggers

IF I % 100 = 0
DOEVENTS
WAIT WINDOW STR(I)+" of " + STR(lnCount)+CHR(13) ;
+STR(I * 100 / lnCount, 6, 2)+"% complete" ;
NOWAIT
ENDIF
NEXT I
WAIT CLEAR

Obviously, somewhere between this basic example and our overall system, something makes it more likely to crash. We haven't found it, and I have a feeling that we aren't going to find it. There's just too many thousands of lines of code (literally).

You may wonder why this example is written the way it is, and that's because I wanted it to be as close to the real code as it can. For example, the GO TOP, GO BOTTOM, GO 1 stuff effectively does nothing, but we found that doing that seemed to reduce the frequency of occurrence of crashes. Also note the creation of the CURSOR every single time - we used to create it once the first time we needed it, and then we used one record in the cursor for each page in our pageframe. We found that getting rid of the cursor after doing the RESTORE FROM seemed to reduce the frequency of occurrence as well, and since we could make that design change transparently, we did it. It slows things down somewhat, but we're willing to accept that in exchange for fewer crashes.

My hunches so far are that there is a bug in VFP when working with memo fields and the RESTORE FROM command that causes internal memory pointers to get corrupted, hence the invalid page fault error. Moving the record pointer and re-establishing the file periodically reduces the frequency of the memory pointer corruption, hence the reduction in invalid page fault errors.

Has anyone else experienced similar problems and perhaps learned more about it and/or discovered any workarounds?
Next
Reply
Map
View

Click here to load this message in the networking platform