PreviousNext

Conformant Arrays Not Allowed

You cannot use conformant arrays in objects stored to a backing store. This is because the IDL-generated code that encodes (pickles) the structure has no way to predict or detect the size of the array. When the object is fetched, there will likely be insufficient space provided for the structure, and the array's data will destroy whatever is in memory after the structure.

To illustrate the problem more clearly, here is an example. An IDL file has a conformant array, na, as an object in a struct:

typedef struct {

unsigned32 length;

[size_is(length)]

unsigned32 numbers[];

} num_array_t

typedef struct {

char *name;

num_array_t na;

} my_type_t;

The idl compiler turns the IDL specification into the following .h file contents:

typedef struct {

unsigned32 length;

unsigned32 numbers[1];

} num_array_t

typedef struct {

idl_char *name;

num_array_t na;

} my_type_t;

When the object is fetched, and the array length is greater than the 1 (one) assumed in the .h file, the decoding operation destroys whatever follows my_struct in memory:

my_type_t my_struct;

dce_db_fetch(dbh, key, &my_struct, &st);

The correct method is to use a pointer to the array, not the array itself, in the IDL file. For example:

typedef struct {

char *name;

num_array_t *na;

} my_type_t;