[omniORB] Problems with String_var

jjeschin@phoenixcontact.com jjeschin@phoenixcontact.com
Tue, 7 Aug 2001 13:43:45 +0200


Thank you very much. It is working now.

Greetings,

Joerg





james.eggleston@vega.de am 06.08.2001 17:10:32

An:    Joerg Jeschin/Phoenix Contact@Phoenix, omniorb-list@uk.research.att.com
Kopie:
Thema: Re:[omniORB] Problems with String_var



Are you using the omniORB DLLs at run time? I had a similar (the same?)
problem... I believe the root of this is caused by a NT rquirement that that if
the omniORB DLLs allocate memory, they should be used to deallocate that memory.
If you look in the kernel code that is detecting the error, it says that memory
cannot be deallocated by a DLL that was not the creator of it.

In hindsight, I should have tried using CORBA::Release() ... maybe I did, I
can't remember.... without doing a test I couldn't tell you for certain. Anyone?

What I understand to happen is your program (in the omniORB dlls) receive the
string from the server, it unmarshalls it and grabs enough memory to handle it.
It then gives you the pointer to the memory.

When the _var goes out of scope, your DLL/EXE deallocates it. (well the _var
deallocates it for you... ) You won't get the problem if all you do is store the
return value in a pointer, and never call delete- though obviously you leak the
memory :) )

Anyway, I found that if you link statically with the omniORB libs you won't get
the error.... since now the code is all in your one DLL/EXE so the unmarshaller
code can use new and your code can use delete. Info on how to build like this is
in 'readme.WIN32'.

I am not really sure why the problem only arises with strings and not for
instance long's. Presumably strings use new/delete and the allocation of the
memory for the longs doesn't, (perhaps the declaration of this memory is done as
a mem_alloc? ..... and doesn't suffer from the same DLL checking by the OS).
Anyone?

Anyway, hope this helps you....

Cheers,
James.

______________________________________________________________________________
James Eggleston                                             tel:  +49 (0) 6151
82570
VEGA Informations-Technologien GmbH              fax: +49 (0) 6151 825799
Julius-Reiber Strasse 19
james.eggleston@vega.de
64293 Darmstadt                                               www.vega.de  or
www.vega.co.uk

This transmission is intended for the named addressee only. It contains
information which may be confidential and which may also be privileged.  Unless
you are the named addressee (or authorised to receive it for the addressee) you
may not copy or use it, or disclose it to anyone else. If you have received this
transmission in error please notify the sender immediately.

______________________________________________________________________________



____________________Reply Separator____________________
Subject:    [omniORB] Problems with String_var
Author: <jjeschin@phoenixcontact.com>
Date:       8/6/01 2:01 PM

I am not familiar with CORBA and try to write my first server application under
WinNT (VC++6.0). I try to pass a string from the client to the server.
Client Code:
  ...
  CORBA::String_var src = (const char*)"/IP=149.208.19.219";
  CORBA::Long hInst;

  ret = IPFBref->RegisterIPTime(hInst, src);
  ...

Server Code:
HRESULT IPFBORBServer_i::RegisterIPTime(CORBA::Long& hFBInst, const char*
strPartner)
{
    printf("RegisterIPTime()\n");
    hFBInst = 0;
    return 0;
}

When the string variable on the server side goes out of scope and the delete
operator is called I get always a debug assertion:
"_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)".
What's my mistake?