Invalid page fault 
Author Message
 Invalid page fault

Hello

From time to time I experience problems with my code and when I test my
ActiveX control in the Test Container I get an invalid page fault.

Here is one I prepared earlier:

TSTCON32 caused an invalid page fault in
module CUBA.DLL at 0167:01c24387.
Registers:
EAX=01d80d50 CS=0167 EIP=01c24387 EFLGS=00010202
EBX=81768de4 SS=016f ESP=0066ef50 EBP=0066ef60
ECX=34313538 DS=016f ESI=0066f060 FS=45ef
EDX=01d80ef0 ES=016f EDI=0066efec GS=0000
Bytes at CS:EIP:
89 41 04 eb 3e 8b 0d 40 cc c5 01 3b 4d fc 74 21
Stack dump:
0066efec 0066f060 81768de4 01d80ef0 0066ef70 01c2407a 01d80f10 00000001
0066ef90 01c2339d 01d80f10 00000001 0066efec 0066f060 81768de4 01d80ef0

What sort of things should I be looking for after experiencing a page fault.

=========================================
Angus Comber

www.onlinesupport.co.uk
On-line Support Computing Ltd
Tel:  020 8940 9484
Fax: 020 8948 2114



Tue, 03 Feb 2004 03:14:53 GMT  
 Invalid page fault
Hi Angus,

Quote:
> From time to time I experience problems with my code and when I test my
> ActiveX control in the Test Container I get an invalid page fault.

> What sort of things should I be looking for after experiencing a page

fault.

Have a look at memory allocation, deallocation and ref-counting:

a) don't free or release [in] parameters
b) return correctly allocated or addreffed [out] parameters or NULL, because
the client will deallocate or release them later on

HRESULT MyCtl::MyMethod(/* [in] */ BSTR SomeText, /* [out] */ BSTR *OutText,
/* [out] */ IMyInterface **OutInterface)
{
   // check out parameters
   if(!OutText)
      return E_POINTER;
   if(!OutInterface)
      return E_POINTER;

   // initialize out parameters
   *OutText = NULL;
   *OutInterface = NULL;
   USES_CONVERSION; // because of some conversion macros...

    // do what ever you want with SomeText but do not call SysFreeString
    // or attach it to a class like CComBSTR which will call SysFreeString
in its destructor
    const char *pszText = OLE2CA(SomeText); // pszText exists on the stack
do not call delete or alike

    // use Sysxxx API
   *OutText = SysAllocString(L"Hello World");

   // OR conversion macro
   *OutText = A2BSTR("42");

   // OR CComBSTR
   CComBstr b;
   b = L"LOL";
   *OutText = b.Detach(); // after Detach() b won't call SysFreeString
anymore

   // use QI for your interface pointer
   if(m_spMyObj != NULL)
      m_spMyObj.QueryInterface(OutInterface); // QI interfaces are AddRef-ed
already

   // OR use Detach of CComPtr or _com_ptr_t
   *OutInterface = spLocalObj.Detach() // Release will no longer be called
on interface in spLocalObj, so don't use this pointer after the method
returned

   // OR assign the pointers directly and DO call AddRef
   *OutInterface = m_pMyObj;
   if(*OutInterface)
     (*OutInterface)->AddRef();

   return S_OK; // or whatever is appropriate

Quote:
}

The ORs are meant as ORs because otherwise some memory should be freed
inbetween ;-)

That is just some COM stuff which you can do wrong...

HTH

bye, Sven



Thu, 05 Feb 2004 21:44:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Invalid page fault in Windows98

2. Invalid Page Fault?

3. Invalid page faults when accessing large arrays

4. caused an invalid page fault in module ...

5. Invalid Page fault in module MSJT3032.DLL

6. Invalid page fault

7. invalid page fault

8. Invalid Page Fault in Release mode with ML compiler option

9. invalid page fault ...

10. MSDEV caused an invalid page fault in Module SSSCC.DLL After Install SP2

11. invalid page fault when I exit my program

12. Help - receiving invalid page fault in kernel32.dll

 

 
Powered by phpBB® Forum Software