0 Replies - 294 Views - Last Post: 31 August 2011 - 08:05 AM Rate Topic: -----

#1 scienalc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 22-July 11

COM server crashes but client receives no exception response

Posted 31 August 2011 - 08:05 AM

Hi, everyone,

I got a problem when writing a method in COM. Namely, it is supposed to send a structure as an out parameter back to the client, more accurately an array of these structures ().
But, one field of this structure is a blob (BYTE = typedef unsigned char) which causes the server to break:

                        ...
			BYTE* dummy = new BYTE[7];
			dummy[0] = 'x'; dummy[1] = 'b'; dummy[2] = 'c'; dummy[3] = 'd'; dummy[4] = 'e';
                        ...
			pItemRes->dwBlobSize = sizeof(*dummy);
			pItemRes->pBlob = dummy;
                        ...



Now the problem: the method executes with no errors, when it finishes (a valid no-exception return), an
"HEAP[OPCDAServerCOM.exe]: Invalid Address specified to RtlFreeHeap( 00150000, 00399368 )" 

error is generated, at the server messageloop. The funny thing is that, even when the server crushes (and it always does), the client still receives the correct out parameters (all of them), only that the blob is limited only to the first character (in this case 'x') and the size 1.

Here is the structure from the .idl:
typedef struct tagOPCITEMRESULT 
{
                        OPCHANDLE  hServer;
                        VARTYPE    vtCanonicalDataType;
                        WORD       wReserved;
                        DWORD      dwAccessRights;
                        DWORD      dwBlobSize;
  [size_is(dwBlobSize)] BYTE*      pBlob;
}
OPCITEMRESULT;



and the method:
    HRESULT AddItems( 
        [in]                     DWORD           dwCount,
        [in, size_is(dwCount)]   OPCITEMDEF*     pItemArray,
        [out, size_is(,dwCount)] OPCITEMRESULT** ppAddResults,
        [out, size_is(,dwCount)] HRESULT**       ppErrors
    );



I guess that I'm making a mistake either in declaring the size to fit the .idl correctly, or I don't use the pointer-array arithmetic in a COM friendly way.

Can anyone make some suggestions how to fix this, or where am I mistaken.
Thank you

Is This A Good Question/Topic? 0
  • +

Page 1 of 1