[omniORB] Win32 Question

Helge Penne Helge.Penne@datarespons.no
Fri, 04 Jun 1999 08:55:27 +0200


"ryan.tecco" wrote:

> All right, here is a little snip of what I am doing. It is basically based
> on the eg2_xxxx samples.
>
> class MyObject : public virtual _sk_MY
> {
> public:
>         MyObject();
>         virtual ~MyObject();
>         virtual char* request();
> };
>
> BOOL CMyDlg::OnInitDialog()
> {
>  ...
>  int argc = 0;
>  CORBA::ORB_ptr orb = CORBA::ORB_init(argc, NULL, "omniORB2");
>  CORBA::BOA_ptr boa = orb->BOA_init(argc, NULL, "omniORB2_BOA");
>  my_impl = new MyObject;
>  my_impl->_obj_is_ready(boa);
>  MY_var objRef = my_impl->_this();
>  CORBA::String_var temp = orb->object_to_string(objRef);
>  std::ofstream outFile("iiop.txt", ios::out);
>  outFile << (char *)temp;
>  outFile.close();
>  boa->impl_is_ready(0, 1);
>  ...
> }
>
> void CVoiceRecDlg::OnCancel()
> {
>         delete my_impl;
>         CDialog::OnCancel();
> }
> --------------
> ryan.tecco
> 734.647.8057
> microcosm/CAVE programmer
> the university of michigan
> "when all the pettiness is gone,
> what do we really have?"
>
> On Thu, 3 Jun 1999, Bruce Visscher wrote:
>
> > Ryan,
> >
> > If I had to make a WAG, it would be that you failed to duplicate an object
> > somewhere in the server.  If you could post a small example with
> > implementation that exhibits the problem then maybe someone could help.
> >
> > Bruce
> >
> > "ryan.tecco" wrote:
> >
> > > I am running WinNT 4.0 SP3 and MSVC++ 6.0. I am writing an MFC
> > > application. One of the objects within the main dialog is a object that
> > > inherits from the CORBA skeleton. My client is able to connect fine, run a
> > > remote method fine, but right after it runs it once, the server throws a
> > > variety of debug assertions located in "object.cc" and some other files. I
> > > switched to the run-time libraries, but then I got a more serious error.
> > > It just looks to me like I am not initializing or doing something properly
> > > (being new to CORBA and all ;) Please let me know any suggestions if this
> > > sounds at all familiar.
> > >
> > > rt
> > >
> > > --------------
> > > ryan.tecco
> > > 734.647.8057
> > > microcosm/CAVE programmer
> > > the university of michigan
> > > "when all the pettiness is gone,
> > > what do we really have?"
> >
> >

Hmmm.  I assume the the remove method that you invoke is char*
MyObject::request(void).  From the description that you gave, I also assume that
the server crashes when request returns (I think it is called by dispatch at some
level).

What would be really useful would be the source code for MyObject::request.  Are
you absolutely sure that you allocate the string that you return the correct way?

If you want to return a string constant, the code should look like this:
char* MyObject::request(void)
{
    return CORBA::string_dup( "Some string constant" );
}

If the string you want to return is a variable in your program, the code should
look like this:
char* MyObject::request(void)
{
    return CORBA::string_dup( szSomeStringVariable );
}

If you return the string itself instead of a copy of the string (allocated with
CORBA::string_dup), all sorts of problems can occur.  Also, the remote client
program should either assign the string to an object of type CORBA::String_var
(which does internal reference counting), or deallocate it after use by calling
CORBA::string_free.

Note that this is all just an edjucated guess, as more source code and a better
description of the first assertion would be needed to do a proper analysis of the
problem.

--
Helge Penne (helge.penne@datarespons.no)
Senior Software Development Engineer
Data Respons AS, Postboks 489, N-1323 Høvik, Norway
Phone: +47 67112081 / 22719957 (work/home)