Summary: | SSLIOP leaks memory and connections on client | ||
---|---|---|---|
Product: | TAO | Reporter: | david.kinder |
Component: | SSLIOP Pluggable Protocol | Assignee: | DOC Center Support List (internal) <tao-support> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 1.4 | ||
Hardware: | x86 | ||
OS: | Windows 2000 | ||
Attachments: |
tarball containing simple client/server which expose problem
Patch for TAO 1.5.6 which fixes problem. |
Description
david.kinder
2003-05-13 04:42:23 CDT
Hi David, Thanks for analyzing the problem. I don't recall the reference count being incremented when calling make_svc_handler(). It looks like this was added after I wrote the code in SSLIOP_Connector.*. Actually, I think it was a bad idea (not mine :-)) to increment the reference count by one in such a factory method since it altered the behavior of code that expected things to work in the canonical way. In particular, a factory method that creates a reference counted object would typically return an object with a reference count equal to one. Instead it is returning an object with a reference count equal to two the first time into this method. Unfortunately, this change to the make_svc_handler() method introduced the problem you detected. Thanks alot for your fix! I'll commit it. However, I'd really like to see that reference count increment in make_svc_handler() removed. Fixed. Mon May 19 11:05:26 2003 Ossama Othman <ossama@dre.vanderbilt.edu> ... From David Kinder <david.kinder@sophos.com> * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp (ssliop_connect): The base_connector_.connect() call will increment the handler's reference count once more. This is not needed as we already hold a reference to the handler. Therefore we discard this second reference. Fixes a memory leak. [Bug 1506] (retrieve_credentials): For the default certificate and private key case, assign the return value of the TAO_SSLIOP_Credentials_var::out() call to a reference to a TAO_SSLIOP_Credentials_ptr. Previously, the return value was assigned to a local TAO_SSLIOP_Credentials_ptr variable that was lost when leaving the scope of this method. Fixes a memory leak. [Bug 1508] This bug was reintroduced in TAO 1.3.4, when a refactoring branch was merged in. To be exact, when revision 1.76 of this file was committed to CVS. The problem is in 1.4.0, and is the same as before: the reference count on svc_handler is incremented twice, but only decremented once, so that SSLIOP connection handlers are never deleted. Inspection with a debugger on a breakpoint immediately after the call to this->base_connector_.connect() in ssliop_connect() shows that the reference count is either three (for success or pending completion) or two (for failure), contrary to the comment in the code immediately below, which states the desired values for the reference count of either two or one. The fix is the same as before: immediately after the base_connector_.connect() call, add the following: // base_connector_.connect() will increment the handler's #REFCOUNT# // once more. This is not required as we already hold a reference to // the handler, so we discard this second reference. svc_handler->remove_reference (); This bug was observed in our production environment. It caused clients to leak file descriptors until they became inoperative. I wrote a simple test setup which demonstrates this problem. I verified that the previously described patch fixes the problem in the test setup. Created attachment 662 [details]
tarball containing simple client/server which expose problem
Created attachment 663 [details]
Patch for TAO 1.5.6 which fixes problem.
Applied the fix from Ken Sedgwick. |