[omniORB] _CORBA_String_helper - inline a good idea and/or on purpose?

Martin Trappel 0xCDCDCDCD at gmx.at
Fri Aug 21 10:38:50 BST 2009


class _CORBA_String_helper vs. CORBA::string_dup

During some testing we had a crash involving some CORBA strings.
Long story short, the reason was that we were testing with Visual Studio 
2008 (VC9) but using omniORB 4.1.2 with the VC8 (VS 2005) DLLs.

The problem was that we were passing the result of CORBA::string_dup to 
a CosNaming::Name structure and when this went out-of-scope the string 
was freed using _CORBA_String_helper.
_CORBA_String_helper is defined inline and ~_CORBA_Unbounded_Sequence 
from which CosNaming::Name is derived is also inline, but 
CORBA::String_dup is not inline, it's inside the omniORB DLL.

So what happended was that the memory that came from CORBA::string_dup 
was actually allocated by the VC8 runtime, but when this memory was 
freed by CosNaming::Name the VC9 runtime was used ==> Heap corruption.

So the question really is (apart from whether its a good idea to use a 
VC8 compile of omniORB with a VC9 app):
Would it make sense to make _CORBA_String_helper non-inline to prevent 
this kind of error?

cheers,
Martin



More information about the omniORB-list mailing list