Sequences

Sai-Lai Lo S.Lo@orl.co.uk
Fri, 10 Oct 1997 14:43:20 +0100


>>>>> J=F6rg Narr writes:

> asv-> length(5);                                       // In a method=

> "eingabe" that is input of CorbaWrapper
=09
> asv[0].slotname  =3D (const char*) "Slotname";          // I have eve=
n
> tried CORBA::string_dup("Slotname");
> asv[0].flag      =3D 120L;
> asv[0].value     =3D (const char*) "Value";
> asv[0].state     =3D (const char*) "State";


> I got a valid Object-Reference, at least CORBA::is_nil(ref) gives bac=
k
> true.

> As soon as I use ref->update(asv) though I get a segmentation fault -=

> core dump.

> This only happens when asv->length isn't set to 1. As long as it is s=
et
> to 1 it works fine.

This happens because you have not instantiated asv[1],asv[2],asv[3],asv=
[4].
Because you have specified that the sequence has 5 elements, the ORB tr=
y to
marshal them in. You may think that the ctor of struct attributes might=

initialize its member to some sensible value. Well, it doesn't.

The C++ mapping of your struct should be thought of as:

 struct attributes=20
  {
    char* slotname;
    long flag;
    char* value;
    char* state;=20
  };

(Actually it isn't because the spec requires that operator=3D have to c=
opy
 the string member transparently.)