[omniORB] CORBA::String_var in generated _dispatch method

Alexandru Harsanyi aharsanyi@com6.fr
Fri, 24 Nov 2000 18:20:07 +0100


Hi!

This may be a stupid question, since I'm new to CORBA...

I have an interface having a method with a string parameter. When I call
the metod (remotely), the implementation code is executed, but back in
the _dispatch method the code crashes when destroying the String_var
object that held the parameter for the method.

Here is the code generated by omniidl for the _dispach method:

    [...]

   CORBA::String_var arg_service;

    {
      CORBA::String_member _0RL_str_tmp;
      _0RL_str_tmp <<=  giop_s;
      arg_service = _0RL_str_tmp._ptr;
      _0RL_str_tmp._ptr = 0;
    }

    [...]

So, I stepped through the code with the debugger and the parameter is
extracted and a char * is allocated by omniorb and assigned to the
arg_service, Than my implementation method is called. When the _dispatch
method returns, and the arg_service is destroyed, VC 6.0 gives an
exception.

If I change the code to:

CORBA::String_var arg_service;

    {
      CORBA::String_member _0RL_str_tmp;
      _0RL_str_tmp <<=  giop_s;
      arg_service = (const char*)_0RL_str_tmp._ptr;
      _0RL_str_tmp._ptr = 0;
    }

thus forcing arg_service to allocate a new buffer for the parameter,
everithing works fine, but the original buffer is never released...

What am I missing here?

Alex.