Bug 1758494

Summary: LeakSanitizer: detected memory leaks in do_add
Product: Red Hat Enterprise Linux 8 Reporter: Viktor Ashirov <vashirov>
Component: 389-ds-baseAssignee: thierry bordaz <tbordaz>
Status: CLOSED ERRATA QA Contact: RHDS QE <ds-qe-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.1CC: lkrispen, mreynolds, nkinder, pasik, spichugi, tbordaz, vashirov
Target Milestone: rcFlags: mreynolds: mirror+
Target Release: 8.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 389-ds-base-1.4.2.4-7.module+el8.2.0+5670+0b8b1c2e Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 16:01:22 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:

Description Viktor Ashirov 2019-10-04 10:04:39 UTC
Description of problem:

=================================================================
==29424==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 2 object(s) allocated from:
    #0 0x7f7dc1abdae8 in __interceptor_malloc (/lib64/libasan.so.5+0xefae8)
    #1 0x7f7dc1325297 in slapi_ch_malloc (/usr/lib64/dirsrv/libslapd.so.0+0xdc297)
    #2 0x7f7dc149c53d in valuearray_add_valuearray_fast (/usr/lib64/dirsrv/libslapd.so.0+0x25353d)
    #3 0x7f7dc149c8ee in valuearray_add_valuearray (/usr/lib64/dirsrv/libslapd.so.0+0x2538ee)
    #4 0x7f7dc130a71f  (/usr/lib64/dirsrv/libslapd.so.0+0xc171f)
    #5 0x7f7dc130df4a in do_add (/usr/lib64/dirsrv/libslapd.so.0+0xc4f4a)
    #6 0x55c689a18934  (/usr/sbin/ns-slapd+0x45934)
    #7 0x7f7dbec11567  (/lib64/libnspr4.so+0x2b567)

Indirect leak of 64 byte(s) in 2 object(s) allocated from:
    #0 0x7f7dc1abdae8 in __interceptor_malloc (/lib64/libasan.so.5+0xefae8)
    #1 0x7f7dc1325297 in slapi_ch_malloc (/usr/lib64/dirsrv/libslapd.so.0+0xdc297)
    #2 0x7f7dc149a6f0 in value_new (/usr/lib64/dirsrv/libslapd.so.0+0x2516f0)
    #3 0x7f7dc149a776 in slapi_value_dup (/usr/lib64/dirsrv/libslapd.so.0+0x251776)
    #4 0x7f7dc149c40d in valuearray_add_valuearray_fast (/usr/lib64/dirsrv/libslapd.so.0+0x25340d)
    #5 0x7f7dc149c8ee in valuearray_add_valuearray (/usr/lib64/dirsrv/libslapd.so.0+0x2538ee)
    #6 0x7f7dc130a71f  (/usr/lib64/dirsrv/libslapd.so.0+0xc171f)
    #7 0x7f7dc130df4a in do_add (/usr/lib64/dirsrv/libslapd.so.0+0xc4f4a)
    #8 0x55c689a18934  (/usr/sbin/ns-slapd+0x45934)
    #9 0x7f7dbec11567  (/lib64/libnspr4.so+0x2b567)

Indirect leak of 18 byte(s) in 2 object(s) allocated from:
    #0 0x7f7dc1abdae8 in __interceptor_malloc (/lib64/libasan.so.5+0xefae8)
    #1 0x7f7dc1325297 in slapi_ch_malloc (/usr/lib64/dirsrv/libslapd.so.0+0xdc297)
    #2 0x7f7dc149a1b2  (/usr/lib64/dirsrv/libslapd.so.0+0x2511b2)
    #3 0x7f7dc149a625 in slapi_value_set_berval (/usr/lib64/dirsrv/libslapd.so.0+0x251625)
    #4 0x7f7dc149a685 in value_init (/usr/lib64/dirsrv/libslapd.so.0+0x251685)
    #5 0x7f7dc149a704 in value_new (/usr/lib64/dirsrv/libslapd.so.0+0x251704)
    #6 0x7f7dc149a776 in slapi_value_dup (/usr/lib64/dirsrv/libslapd.so.0+0x251776)
    #7 0x7f7dc149c40d in valuearray_add_valuearray_fast (/usr/lib64/dirsrv/libslapd.so.0+0x25340d)
    #8 0x7f7dc149c8ee in valuearray_add_valuearray (/usr/lib64/dirsrv/libslapd.so.0+0x2538ee)
    #9 0x7f7dc130a71f  (/usr/lib64/dirsrv/libslapd.so.0+0xc171f)
    #10 0x7f7dc130df4a in do_add (/usr/lib64/dirsrv/libslapd.so.0+0xc4f4a)
    #11 0x55c689a18934  (/usr/sbin/ns-slapd+0x45934)
    #12 0x7f7dbec11567  (/lib64/libnspr4.so+0x2b567)

SUMMARY: AddressSanitizer: 114 byte(s) leaked in 6 allocation(s).

Version-Release number of selected component (if applicable):
389-ds-base-1.4.1.3-7.module+el8.1.0+4150+5b8c2c1f.x86_64


How reproducible:
always

Steps to Reproduce:
1. Rebuild 389-ds-base with ASAN
2. Run tests/suites/basic/basic_test.py::test_basic_referrals
3.

Actual results:
Memory leaks are reported by ASAN

Expected results:
No errors from ASAN

Additional info:
Might be already fixed by https://pagure.io/389-ds-base/pull-request/50523

Comment 2 thierry bordaz 2020-01-22 12:49:35 UTC
This leak is fixed in master.

The leak occurred when nsslapd-unhashed-pw-switch == off. nsslapd-unhashed-pw-switch default value was recently changed to 'off' that explains why we did not detect the leak before (with the same test case)

As suggested in the bug description it was fixed with https://pagure.io/389-ds-base/pull-request/50523 (git log -p -1 340f23990199698cb42b4a4e2686d3c404745800 ldap/servers/slapd/add.c)
It was fixed without BZ so switch this bug to POST

Comment 4 Viktor Ashirov 2020-02-24 12:42:43 UTC
====================================================================================================== test session starts ======================================================================================================
platform linux -- Python 3.6.8, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- /usr/bin/python3.6
cachedir: .pytest_cache
metadata: {'Python': '3.6.8', 'Platform': 'Linux-4.18.0-179.el8.x86_64-x86_64-with-redhat-8.2-Ootpa', 'Packages': {'pytest': '5.3.5', 'py': '1.8.1', 'pluggy': '0.13.1'}, 'Plugins': {'metadata': '1.8.0', 'html': '2.0.1'}}
389-ds-base: 1.4.2.4-7.1asan.el8
nss: 3.44.0-15.el8
nspr: 4.21.0-2.el8_0
openldap: 2.4.46-11.el8
cyrus-sasl: 2.1.27-1.el8
FIPS: disabled
rootdir: /mnt/tests/rhds/tests/upstream/ds/dirsrvtests, inifile: pytest.ini
plugins: metadata-1.8.0, html-2.0.1
collected 1 item

ds/dirsrvtests/tests/suites/basic/basic_test.py::test_basic_referrals PASSED                                                                                                                                              [100%]

================================================================================================ 1 passed, 16 warnings in 23.23s ================================================================================================

Automated test passed, no leaks reported.
Marking as VERIFIED.

Comment 6 errata-xmlrpc 2020-04-28 16:01:22 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.

https://access.redhat.com/errata/RHBA-2020:1703