Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TIP - Invalid Page Faults
Message
From
27/08/1999 22:40:20
 
 
To
27/08/1999 22:08:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00258020
Message ID:
00258741
Views:
15
Yes, it makes no difference. Try it yourself - it will only take a minute to reproduce.

The problem is that NEWOBJECT() does an implicit SET CLASSLIB TO "c:\program files\microsoft visual studio\vfp98\testgfp.vcx" and before it has a chance to reset, SET("CLASSLIB") returns the same to .cSetClassLib and SET CLASSLIB TO fails in the Init().

It works fine the first time, but without CLEAR ALL, an Invalid Page Fault occurs the second time the object is instantiated - corrupt cache?

While at first glance this seems like one of those one-in-a-million cases, it could create problems with complex objects that instantiate other objects (in the Init()) which, in turn, attempt to use the SET CLASSLIB Command or possibly NEWOBJECT().


>Jeff,
>Did you test this with name expression instead of macro substitution ?
>(lcSetClassLib) instead of &lcSetClassLib.
>Cetin
>>Sorry, I gave you a typo (wrong ClassLib) - it should be this:
>>
>>Now from the Command Window, type:
>>
>>oCrash = NEWOBJECT("cusgfp", "c:\program files\microsoft visual studio\vfp98\testgfp.vcx")
>>RELEASE oCrash
>>oCrash = NEWOBJECT("cusgfp", "c:\program files\microsoft visual studio\vfp98\testgfp.vcx")
>>
>>
>>>Dave,
>>>
>>>Create the following class:
>>>
>>>*-- Class: cusgfp (c:\program files\microsoft visual studio\vfp98\testgfp.vcx)
>>>*-- ParentClass: custom
>>>*-- BaseClass: custom
>>>*-- Time Stamp: 08/27/99 08:47:11 AM
>>>
>>>
>>>DEFINE CLASS cusgfp AS custom
>>>
>>>	cSetClassLib = ""
>>>	Name = "cusgfp"
>>>
>>>	PROCEDURE Init
>>>		This.cSetClassLib = SET("CLASSLIB")
>>>		SET CLASSLIB TO
>>>	ENDPROC
>>>
>>>	PROCEDURE Destroy
>>>		LOCAL lcSetClassLib
>>>
>>>		lcSetClassLib = This.cSetClassLib
>>>		SET CLASSLIB TO &lcSetClassLib
>>>	ENDPROC
>>>
>>>ENDDEFINE
>>>
>>>
>>>Now from the Command Window, type:
>>>
>>>oCrash = NEWOBJECT("cusgfp", "c:\program files\microsoft visual studio\vfp98")
>>>RELEASE oCrash
>>>oCrash = NEWOBJECT("cusgfp", "c:\program files\microsoft visual studio\vfp98")
>>>
>>>BLAMO
>>>
>>>The Invalid Page Fault occurs when you instantiate the object the second time. This makes sense due to my understanding of an implicit SET CLASSLIB when using NEWOBJECT for object instantiation.
>>>
>>>While one may say that someone would be insane to use a class like the one above, some objects instantiate other objects which instantiate other... and so on. I found this problem with my framework's application object which fires an environment object used to set/reset global SETS - including SET CLASSLIB.
>>>
>>>
>>>
>>>>Please provide a code sample. Your steps below are confusing to me.
>>>>
>>>>Thanks,
>>>>
>>>>Dave
>>>>
>>>>>I have found a special case that is guaranteed to cause a VFP Invalid Page Fault and, therefore, should be avoided:
>>>>>
>>>>>- NEWOBJECT(CLassName, CLassLibrary) is used to instantiate an object and ;
>>>>>
>>>>>- SET CLASSLIB TO is issued before the instantiation of the object is complete and ;
>>>>>
>>>>>- SET CLASSLIB TO ClassLibrary (same class library) is issued after the instantiation of the object is complete and ;
>>>>>
>>>>>- The object is released and ;
>>>>>
>>>>>- NEWOBJECT(CLassName, CLassLibrary) is used to instantiate the object again, THEN ;
>>>>>
>>>>>blamo - VFP Invalid Page Fault every time.
- Jeff
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform