Raising events quickly from DLL server crashes the client

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Ok,

I don't know which is the cause, but I've noted that if I raise some
events quickly, my VB6 client crashes.

In the beginning I thought it was the "Firing events from a worker
thread" issue so I've changed my Proxy_ class with the code from
codeguru (http://www.codeguru.com/Cpp/COM-Tech/atl/atl/article.php/
c75) because I was not able to use the ATLCPImplMT.h from MS with
VC2008.

So, when I run my client app from the IDE attached to the VC debugger
all works....
When if I load the exe (always throught the debugger) and I fire
events quickly I get:

Unhandled exception at 0x73459a49 in EuroATLibTest.exe: 0xC0000005:
Access violation reading location 0x00000034.

on the line:

hr = pDispatch->Invoke(3, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &params, &varResult, NULL, NULL);

This is the line where I raise this event:

HRESULT Fire_OnStatusChanged( E_AT_DEV_STATE newStatus)
{

HRESULT hr = S_OK;
T * pThis = static_cast<T *>(this);
int cConnections = m_vec.GetSize();

for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();

CComQIPtr< IDispatch, &IID_IDispatch > pDispatch
( punkConnection.p );

if (pDispatch.p != NULL)
{
CComVariant avarParams[1];
avarParams[0] = newStatus;
CComVariant varResult;
DISPPARAMS params = { avarParams, NULL, 1, 0 };
hr = pDispatch->Invoke(3, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &params, &varResult, NULL, NULL);
}
}
return hr;
}

Could someone give me some suggestion on fix this problem?!

Thanks,
Daniele.
.



Relevant Pages

  • Re: Dll Security
    ... solution even if i just raise the bar. ... > program detect that it is being run in a debugger (not a trivial task and ... >>I'm encrypting the dll with a program, then when i want to loadlibraryit, ...
    (SecProg)
  • Re: Dll Security
    ... i'm using EFS to protect my plain-text dll. ... The first guy who comes along with a debugger will have little to no problem ... You can't even raise your priority ...
    (SecProg)
  • Re: Divisions of labor
    ... > debugger guru, you don't know how much you would use the debugger ... > All of programming isn't debugging, so becoming a master of the debugger ... > Another question that I'd like to raise is, ... > Slashdot) result in an improvement of productivity immediately. ...
    (comp.lang.python)
  • Re: Abort instead of throwing exceptions
    ... ChessManiac wrote: ... > With the debugger I see the following: ... The third party code looks like it double throws (raise() twice in the ... Do you know which exception is being thown? ...
    (comp.lang.cpp)