[omniORB] extracting struct containing objref from any throws exception

Sai-Lai Lo S.Lo@orl.co.uk
11 Aug 1998 11:53:24 +0100


I cannot reproduce the error you have reported. This is the test code I
wrote base on the information you've supplied. The parameters have been
marshalled and unmashalled correctly (on Solaris 2.5). You may want to
repeat the test yourself.

By the way, there are some obvious typos in your code and the type
SearchParms is missing fom the IDL. Next time, please make sure that the
information given is sufficent and accurate for us to do anything about it.

Regards,

Sai-Lai



CHRISTOPHER WOOD <chrisw@cs.uwa.edu.au> writes:

> I'm having trouble transmitting a struct containing an any which contains
> a further struct which contains an object reference. 
> 
> strangeley enough the error only occours once the containing structure is
> transmitted over the network. If the struct is inserted into the any and
> immediatley removed no exception is thrown.
> 
> unfortunatly i cannot trace the code further due to gdb being unable to
> trace multithreaded code, although i've tried almost every exception type
> listed in the CORBA documentation without the IDL:


---------- bug980811.idl -------------

struct SearchData {
  any datSearchParms;
  any datPopParms;
};

interface CreateInfo {
  readonly attribute SearchData aSearchData;
  void remove();
};

struct LongRange {
  long min;
  long max;
  unsigned long gran;
};

struct PopParms {
  LongRange rngPopSize;
  CreateInfo pChildCreateInfo;
};

typedef PopParms SearchParms;


---------- server.cc ----------------

#include <iostream.h>
#include <bug980811.hh>

CORBA::BOA_ptr boa;

class c_i : public virtual _sk_CreateInfo {
public:
  c_i() {
    _obj_is_ready(boa);
    sp.rngPopSize.min = 0;
    sp.rngPopSize.max = 100;
    sp.rngPopSize.gran = 100;
    sp.pChildCreateInfo = _this();
    
    pp.rngPopSize.min = 5;
    pp.rngPopSize.max = 500;
    pp.rngPopSize.gran = 500;
    pp.pChildCreateInfo = _this();
  }

  SearchData* aSearchData() {
    SearchData* pSearchData = new SearchData;
    pSearchData->datSearchParms <<= sp;
    pSearchData->datPopParms <<= pp;
    return pSearchData;
  }
  void remove() {}
private:
  SearchParms sp;
  PopParms   pp;
};


int
main(int argc, char **argv)
{
  CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv,"omniORB2");
  boa = orb->BOA_init(argc,argv,"omniORB2_BOA");

  c_i* myobj = new c_i;
  {
    CreateInfo_var myobjRef = myobj->_this();
    CORBA::String_var p = orb->object_to_string(myobjRef);
    cerr << (char*)p << endl;
  }
  boa->impl_is_ready();

  return 0;
}


---------- client.cc ----------------

#include <iostream.h>
#include <bug980811.hh>

CORBA::ORB_ptr orb;

int
main (int argc, char **argv) 
{
  orb = CORBA::ORB_init(argc,argv,"omniORB2");

  if (argc < 2) {
    cerr << "usage: client <stringified IOR>" << endl;
    return 1;
  }

  CORBA::Object_var o = orb->string_to_object(argv[1]);
  CreateInfo_var obj = CreateInfo::_narrow(o);

  if (CORBA::is_nil(obj)) {
    cerr << "Cannot convert stringified IOR to an object reference."
	 << endl;
    return 1;
  }


  SearchData_var pSearchData = obj->aSearchData();

  cerr << "Extract datSearchParms..";
  SearchParms* lsp;
  if(pSearchData->datSearchParms >>= lsp) {
    // Note: storage of *lsp is still own by datSearchParms, do not call
    // delete on lsp.
    if (lsp->rngPopSize.min != 0 ||
	lsp->rngPopSize.max != 100 ||
	lsp->rngPopSize.gran != 100 ||
	!(lsp->pChildCreateInfo->_is_equivalent(obj))) {
      cerr << "Error: got wrong value in datSearchParms." << endl;
      return 1;
    }
  }
  cerr << "PASSED." << endl;

  cerr << "Extract datPopParms..";
  PopParms* lpp;
  if(pSearchData->datPopParms >>= lpp) {
    // Note: storage of *lpp is still own by datPopParms, do not call
    // delete on lpp.
    if (lpp->rngPopSize.min != 5 ||
	lpp->rngPopSize.max != 500 ||
	lpp->rngPopSize.gran != 500 ||
	!(lpp->pChildCreateInfo->_is_equivalent(obj))) {
      cerr << "Error: got wrong value in datPopParms." << endl;
      return 1;
    }
  }
  cerr << "PASSED." << endl;
  return 0;
}






-- 
Dr. Sai-Lai Lo                          |       Research Scientist
                                        |
E-mail:         S.Lo@orl.co.uk          |       Olivetti & Oracle Research Lab
                                        |       24a Trumpington Street
Tel:            +44 223 343000          |       Cambridge CB2 1QA
Fax:            +44 223 313542          |       ENGLAND