Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 906005

Summary: Valgrind reports memleak in modify_update_last_modified_attr
Product: Red Hat Enterprise Linux 6 Reporter: Ján Rusnačko <jrusnack>
Component: 389-ds-baseAssignee: Rich Megginson <rmeggins>
Status: CLOSED ERRATA QA Contact: Sankar Ramalingam <sramling>
Severity: high Docs Contact:
Priority: urgent    
Version: 6.4CC: dpal, jgalipea, jwest, nhosoi, nkinder, tlavigne
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 389-ds-base-1.2.11.15-14.el6_4 Doc Type: Bug Fix
Doc Text:
Previously, the vagrind test suite reported recurring memory leaks in the modify_update_last_modified_attr() function. The size of the leaks averaged between 60-80 bytes per the modify call. In environments where modify operations were frequent, this caused significant problems. Now, memory leaks no longer occur in the modify_update_last_modified_attr() function
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 21:00:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 910995    
Attachments:
Description Flags
Valgrind output none

Description Ján Rusnačko 2013-01-30 15:41:02 UTC
Created attachment 690427 [details]
Valgrind output

Version-Release number of selected component (if applicable):
389-ds-base-1.2.11.15-11.el6.x86_64 

Steps to Reproduce:
1) setup the directory server to run under valgrind
2) run the managed entry and DNA tests from TET
3) the valgrind output should not report leaks or errors in modify_update_last_modified_attr

  
Actual results:

==25841== 69 bytes in 1 blocks are definitely lost in loss record 935 of
1,653
==25841==    at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
==25841==    by 0x3F166157F8: PR_Realloc (in /lib64/libnspr4.so)
==25841==    by 0x3F166126E6: ??? (in /lib64/libnspr4.so)
==25841==    by 0x3F16611D7C: ??? (in /lib64/libnspr4.so)
==25841==    by 0x3F166125D9: PR_vsmprintf (in /lib64/libnspr4.so)
==25841==    by 0x4C564A3: slapi_ch_smprintf (ch_malloc.c:433)
==25841==    by 0x4C9C7D7: plugin_get_dn (plugin.c:2567)
==25841==    by 0x4C93686: modify_update_last_modified_attr (opshared.c:170)
==25841==    by 0x4C8E800: op_shared_modify (modify.c:811)
==25841==    by 0x4C8F1B0: modify_internal_pb (modify.c:616)
==25841==    by 0xB20685C: dna_be_txn_pre_op (dna.c:2074)
==25841==    by 0x4C9DD89: plugin_call_func (plugin.c:1453)
==25841==    by 0x4C9DFBE: plugin_call_plugins (plugin.c:1415)
==25841==    by 0xB657235: ldbm_back_add (ldbm_add.c:747)
==25841==    by 0x4C4E6CD: op_shared_add (add.c:681)
==25841==    by 0x4C4FA93: do_add (add.c:258)
==25841==    by 0x414193: connection_threadmain (connection.c:578)
==25841==    by 0x3F16629A72: ??? (in /lib64/libnspr4.so)
==25841==    by 0x3F13E07850: start_thread (in /lib64/libpthread-2.12.so)
==25841==    by 0x3F136E890C: clone (in /lib64/libc-2.12.so)

Comment 2 Noriko Hosoi 2013-01-30 19:27:50 UTC
This leak is fixed in master in the fix for ticket 495...
==25841== 69 bytes in 1 blocks are definitely lost in loss record 935 of
1,653
==25841==    at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
==25841==    by 0x3F166157F8: PR_Realloc (in /lib64/libnspr4.so)
==25841==    by 0x3F166126E6: ??? (in /lib64/libnspr4.so)
==25841==    by 0x3F16611D7C: ??? (in /lib64/libnspr4.so)
==25841==    by 0x3F166125D9: PR_vsmprintf (in /lib64/libnspr4.so)
==25841==    by 0x4C564A3: slapi_ch_smprintf (ch_malloc.c:433)
==25841==    by 0x4C9C7D7: plugin_get_dn (plugin.c:2567)
==25841==    by 0x4C93686: modify_update_last_modified_attr (opshared.c:170)

commit f33e73fe45225c0c7413d74dc846cead3214a404
Author: Mark Reynolds <mreynolds>
Date:   Fri Oct 19 15:55:54 2012 -0400

    Ticket 495 - internalModifiersname not updated by DNA plugin

@@ -135,7 +135,8 @@ do_ps_service(Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype, ber_int_t c
     (ps_service_fn)(e, eprev, chgtype, chgnum);
 }
 
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
-void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
+void
+modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
 {
     char        buf[20];
     char        *plugin_dn = NULL;
@@ -159,11 +160,14 @@ void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
         /* plugin bindDN tracking is enabled, grab the bind dn from thread local storage */
         if(slapi_sdn_isempty(&op->o_sdn)){
             bv.bv_val = "";
-            bv.bv_len = strlen(bv.bv_val);
+            bv.bv_len = 0;
         } else {
             slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &cid);
-            if (cid)
+            if (cid){
                 plugin=(struct slapdplugin *) cid->sci_plugin;
+            } else {
+                slapi_pblock_get (pb, SLAPI_PLUGIN, &plugin);
+            }
             if(plugin)
                 plugin_dn = plugin_get_dn (plugin);
             if(plugin_dn){
@@ -176,6 +180,7 @@ void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods)
         }
         slapi_mods_add_modbvps(smods, LDAP_MOD_REPLACE | LDAP_MOD_BVALUES,
                                   "internalModifiersName", bvals);
+        slapi_ch_free_string(&plugin_dn);
==========================================
         /* Grab the thread data(binddn) */
         slapi_td_get_dn(&binddn);

Comment 9 Ján Rusnačko 2013-08-27 12:28:34 UTC
Verified on 389-ds-base-1.2.11.15-22.el6.x86_64

Comment 10 errata-xmlrpc 2013-11-21 21:00:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1653.html