[omniORB] Memory leak

Duncan Grisby duncan at grisby.org
Wed Jan 25 18:37:53 GMT 2012


On Tue, 2012-01-17 at 14:16 +0400, Tatiana Lazareva wrote:

> It seems that I find some memory leak bugs in omni4.1.6 code. These
> memory leak bugs were detected using the purify tool on the Solaris10
> OS.
> 1) /omniORB-4.1.6/src/lib/omniORB/orbcore/tcp/tcpTransportImpl.cc:
> line 426:

That's a genuine leak. I'll fix it. It's a one-off thing, though, so it
doesn't build up over time.

> 2) /omniORB-4.1.6/src/lib/omnithread/posix.cc: line 376
>     omni_thread* t = new omni_thread; [TLazareva]: This is 376 line.
> "t" object was not deleted at the end of function. Is it correct?

That code is correct. t is the omni_thread object corresponding to the
main thread. If you delete it, everything will break!  The thread is
deleted when the very last module that #included omnithread.h is
unloaded. Presumably Purify is running before that.

> 3) /omniORB-4.1.6/src/lib/omniORB/orbcore/portableserver.cc: line 320

That is per-thread state, presumably attached to the omni_thread that
Purify incorrectly thinks is leaked. There is no leak here.

> 4) /omniORB-4.1.6/src/lib/omnithread/threaddata.cc: line 51

This is storage for the per-thread state. It is not leaked.

> 5) /omniORB-4.1.6/build/src/lib/omniORB/omniORB4/Naming.hh: line 404
>     static inline _ptr_type _unmarshalObjRef(cdrStream& s) {
>       omniObjRef* o =
> omniObjRef::_unMarshal(_PD_repoId,s); [TLazareva]: This is 404
> line.The object "o" is created using "new" operator
> in /omniORB-4.1.6/build/src/lib/omniORB/omniORB4/NamingSK.cc file at
> the 2746 line (full stack you can find below). I think that "o" object
> should be deleted before the "return" like this:
> if (o) {
>   _ptr_type ptrObj = (_ptr_type) o->_ptrToObjRef(_PD_repoId);
>   delete o;
>   return ptrObj;
> }

That is not a leak in omniORB. The return value is a pointer into the
omniObjRef object, so you mustn't delete it there. There is probably a
leak in your code where it fails to release an object reference.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --





More information about the omniORB-list mailing list