BUG: RPC Encoding API MyType_Encode() Causes Access ViolationLast reviewed: February 25, 1998Article ID: Q181651 |
The information in this article applies to:
SYMPTOMSIf you define MyType as a structure with a union that has structures as union_arms in your IDL file, the Midl generated type encoding function, MyType_Encode(), may fail with the following error code:
0xC0000005 Access Violation CAUSEIn some specific cases, a union that contains structures may cause Midl to produce incorrect offset for the description of the structure. As a result, the Midl generated stub routine crashes in the marshaling engine.
RESOLUTIONChange your union member inside MyType from a flat member to a pointer type.
Sample CodeFor example, given the following type definitions:
typedef enum _MyStructEnum { MyStructEnum1, MyStructEnum2 } MyStructEnum; typedef struct _MyStruct1 { char foo; } MyStruct1; typedef struct _MyStruct2 { long length; [size_is(length)] char* bytes; } MyStruct2; // A union with structs as arms. typedef [switch_type(MyStructEnum)] union { [case(MyStructEnum1)] MyStruct1 myStruct1; [case(MyStructEnum2)] MyStruct2 myStruct2; } MyUnion;Change the myUnion field of MyType listed below:
typedef struct _MyType { long someData; MyStructEnum whichStruct; [switch_is(whichStruct)] MyUnion myUnion; } MyType;to a pointer to MyUnion as follows:
typedef struct _MyType { long someData; MyStructEnum whichStruct; [switch_is(whichStruct)] MyUnion *myUnion; } MyType; STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
REFERENCESX/Open DCE: Remote Procedure Call
|
Additional query words: Type, Encoding, Midl, union_arms
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |