Bug 644784 - Memory leak in "testbind.c" plugin
Summary: Memory leak in "testbind.c" plugin
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: 389
Classification: Retired
Component: Directory Server
Version: 1.2.7
Hardware: All
OS: Linux
low
high
Target Milestone: ---
Assignee: Rich Megginson
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks: 639035 389_1.2.8
TreeView+ depends on / blocked
 
Reported: 2010-10-20 09:13 UTC by Paolo Campegiani
Modified: 2015-12-10 18:39 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-12-10 18:39:08 UTC
Embargoed:


Attachments (Terms of Use)

Description Paolo Campegiani 2010-10-20 09:13:59 UTC
Description of problem:

This relates to the plugin testbind.c, available at:

http://cvs.fedoraproject.org/viewvc/ldapserver/ldap/servers/slapd/test-plugins/?root=dirsec

I have tested this plugin on "Red Hat Directory Server", but I guess that LDAP API is the same, so the problem will probably also hit "389 Directory Server" (and there is not a "Red Hat Directory Server" bugzilla section).

Version-Release number of selected component (if applicable):

Checked on Red Hat Directory Server version 8.1.0-0.14

How reproducible:

In the source code of testbind.c, there is:

rc = slapi_search_internal_get_entry( sdn, attrs, &e, plugin_id );

which, according to the Red Hat Directory Server Plugin Guide:

(http://docs.redhat.com/docs/en-US/Red_Hat_Directory_Server/8.2/html/Plug-in_Guide/Plugin_Programming_Guide-Function_Reference-slapi_search_internal_get_entry.html)

"set a copy of the entry", and " The returned entry (*ret_entry) should be freed by calling slapi_entry_free()."

In the code, there is no slapi_entry_free(). So the code should be changed with:


slapi_entry_free(e);
slapi_send_ldap_result( pb, rc, NULL, NULL, 0, NULL );
return( 1 );


where the first line is added, and the other two are from the original source code.

Doing this, there are still some memory leaks on the Directory Server, but they appears to be one shot (i.e. at startup time) and not recurring for every bind() client operation.

With valgrind, I get at "service dirsrv stop" this:

[...]
==29572== LEAK SUMMARY:
==29572==    definitely lost: 14,816 bytes in 312 blocks
==29572==    indirectly lost: 226,940 bytes in 11,067 blocks
==29572==      possibly lost: 40,773 bytes in 347 blocks
==29572==    still reachable: 8,201,212 bytes in 23,240 blocks
==29572==         suppressed: 0 bytes in 0 blocks


And these values are almost constant; otherwise, you see changing numbers (and increasing vsz size on ps output) according to the number of plugin invocations.



Note: this is already documented for the SUN Java System Directory Server:

http://forums.sun.com/thread.jspa?threadID=5050942

Comment 1 Rich Megginson 2011-03-07 18:28:18 UTC
To ssh://git.fedorahosted.org/git/389/ds.git
   4f30419..df575d3  master -> master
commit df575d3d65a31237bed4cb89db165ed00c0331a7
Author: Rich Megginson <rmeggins>
Date:   Mon Mar 7 11:24:39 2011 -0700
    Reviewed by: rmeggins (submitted by paolo.campegiani)
    Branch: master
    Fix Description: Free the entry
    Platforms tested: RHEL6 x86_64
    Flag Day: no
    Doc impact: no
To ssh://git.fedorahosted.org/git/389/ds.git
   b6c75e3..c1bfc3e  389-ds-base-1.2.8 -> 389-ds-base-1.2.8
commit c1bfc3e05a402059b8a95f57897b4622bd7b3813
Author: Rich Megginson <rmeggins>
Date:   Mon Mar 7 11:24:39 2011 -0700

Comment 2 Rich Megginson 2011-11-03 14:33:42 UTC
changed to block DSIPA2.0 because this code is in 389-ds-base-1.2.9.x


Note You need to log in before you can comment on or make changes to this bug.