AW: Re: AW: Re: [omniORB] Debug Assertion Failed although compiled with *.rtd.lib and run the Debug.exe?

baileyk@schneider.com baileyk@schneider.com
Thu Dec 12 16:24:01 2002


I'm sorry, it looks like CORBA::wstring_dup is not inlined.  However, the
approach Duncan suggested is inlined, so there's a clue as to why the
behavior is different.

Look at wstringtypes.h in the omniORB distribution.  The StringList_out
type is going to return a _CORBA_WString_element temporary object from the
operator[] that you are calling.  That temporary's operator=() is being
called.  Here's the two methods

  inline _CORBA_WString_element& operator=(_CORBA_WChar* s) {
    if (pd_rel)
      _CORBA_WString_helper::free(pd_data);
    pd_data = s;
    return *this;
  }

  inline _CORBA_WString_element& operator= (const _CORBA_WChar* s) {
    if (pd_rel)
      _CORBA_WString_helper::free(pd_data);
    if (s)
      pd_data = _CORBA_WString_helper::dup(s);
    else
      pd_data = 0;
    return *this;
  }

So you see, if the type on the right hand side is const, there is a call to
_CORBA_WString_helper::dup(s), which is also inlined (in the same header
file), to do the actual memory allocation ( using new [] ).  The
CORBA::wstring_dup() function is not inlined, but just calls
_CORBA_WString_helper::dup(s) also, so theoretically the effect should be
exactly the same.  CORBA::wstring_dup() returns a non-const WChar*, so the
first function above would be called if you use wstring_dup() explicitly.
If you take Duncan's approach, the second method above should be called and
the dup is done inlined.

You didn't make it clear what exactly calling CORBA::wstring_dup() causes
to happen in GIOP_S.cc.  I can only assume that getting distinct behavior
with the const cast and wstring_dup() call means there is a mix of runtime
libraries in your process.  It's been a few years since I've done heavy
Windows C++ dev work, but I know how difficult it is to track that down.

My suggestion #2 translates into:  change the _CORBA_WString_helper class
so that all of it's methods are non-inlined (i.e. put the implementations
into the same source file that has CORBA::wstring_dup) and recompile
omniORB.  Then there's no chance that string allocation/deallocation across
DLL boundaries is causing your problem (as long as you follow either
Duncan's or my advice on how to assign values to sequence<[w]string>
elements).

You still need to track down your root problem though - linking multiple
runtime libraries.

disclaimer:  I could be way off base, but this is the best advice I can
give based on my Windows C++ development experience.



Kendall



                                                                                                               
                    "Uli Syber"                                                                                
                    <uli.syber@sch       To:     baileyk@schneider.com                                         
                    raml.de>             cc:     omniorb-list@omniorb-support.com                              
                                         Fax to:                                                               
                    12/12/2002           Subject:     AW: Re: AW: Re: [omniORB] Debug Assertion Failed         
                    09:13 AM              although compiled with *.rtd.lib and run the Debug.exe?              
                                                                                                               
                                                                                                               




Hi Kendall,

thank you very much for your help.
When I test with CORBA::wstring_dup() then the compiler runs into GIOP_S.cc
and stops there. Therefore I didin´t apply your hint with
this method.
What do mean by
>... string allocation functions are not inlined..


greetings,
Uli

> -----Ursprüngliche Nachricht-----
> Von: baileyk@schneider.com
> Gesendet: Donnerstag, 12. Dezember 2002 15:19
> Betreff: Re: AW: Re: [omniORB] Debug Assertion Failed although compiled
with *.rtd.lib and run the Debug.exe?
>
>
> I would try two things:
>
> 1. Make an explicit call to CORBA::wstring_dup() rather than rely on the
> implicit call that the const* should trigger.
>
> 2. If that doesn't work (and I doubt it will), then modify omniORB in
such
> a way that the string allocation functions are not inlined and then
> recompile omniORB and your application.
>
> If number 2 works, then there is still a mix of different runtime
libraries
> in your process.  You would need to do a careful link dependency analysis
> to find the problem.
>
> Kendall
>
>
>
>
>

>                     "Uli Syber"

>                     <uli.syber@schraml.de>             To:     "Duncan
Grisby" <duncan@grisby.org>
>                     Sent by:                           cc:
omniorb-list@omniorb-support.com
>                     omniorb-list-admin@omniorb-s       Fax to:

>                     upport.com                         Subject:     AW:
Re: [omniORB] Debug Assertion Failed although
>                                                         compiled with
*.rtd.lib and run the Debug.exe?
>

>                     12/12/2002 07:05 AM

>

>

>
>
>
>
> Hi Duncan,
>
> thanks a lot for your help. When I try to fill the wstring sequence with
a
> wstring from an array and send it, the Assertion appears again.
>
> void Echo_i::echoString(Example::StringList_out idList,CORBA::Long&
length)
> {
>            wchar_t** list;
>            list=getIDList(&len);          //return((wchar_t**)idList);
>
>            idList = new Example::StringList(len);
>            idList->length(len);
>            length=len;
>
>            for(i=0;i<len;i++)
>            {
>
>                           (*idList)[i] =(const CORBA::WChar*)list[i];
>
>                      CoTaskMemFree(list[i]);
>                      //wprintf(L"myList: %s\n",*(List+i));
>            }
> }
>
>
> with greetings,
> Uli
>
>
>
>
> _______________________________________________
> omniORB-list mailing list
> omniORB-list@omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list