Bug 2115348

Summary: memory leak with filter optimizer
Product: Red Hat Enterprise Linux 9 Reporter: mreynolds
Component: 389-ds-baseAssignee: mreynolds
Status: CLOSED ERRATA QA Contact: RHDS QE <ds-qe-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 9.1CC: aadhikar, gkimetto, ldap-maint, progier
Target Milestone: rcKeywords: Triaged
Target Release: 9.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: sync-to-jira
Fixed In Version: 389-ds-base-2.1.3-3.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 10:30:16 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 mreynolds 2022-08-04 13:18:32 UTC
Description of problem:
 
Looks like we have some memory leaks caused by the filter optimizer RFE:

Indirect leak of 120 byte(s) in 10 object(s) allocated from:
    #0 0x7fc6a5cae377 in strdup (/lib64/libasan.so.6+0x5a377)
    #1 0x7fc6a54db0bb in slapi_ch_strdup ldap/servers/slapd/ch_malloc.c:196
    #2 0x7fc6a54ca26c in slapi_attr_syntax_normalize ldap/servers/slapd/attrsyntax.c:539
    #3 0x7fc6a5535bac in filter_normalize_ava ldap/servers/slapd/filter.c:1046
    #4 0x7fc6a5536a4f in filter_normalize_ext ldap/servers/slapd/filter.c:1144
    #5 0x7fc6a5536916 in filter_normalize_list ldap/servers/slapd/filter.c:1118
    #6 0x7fc6a5536ca0 in filter_normalize_ext ldap/servers/slapd/filter.c:1165
    #7 0x7fc6a5536916 in filter_normalize_list ldap/servers/slapd/filter.c:1118
    #8 0x7fc6a5536c64 in filter_normalize_ext ldap/servers/slapd/filter.c:1162
    #9 0x7fc6a5536d8b in slapi_filter_normalize ldap/servers/slapd/filter.c:1184
    #10 0x7fc69d54d083 in ldbm_back_search ldap/servers/slapd/back-ldbm/ldbm_search.c:959
    #11 0x7fc6a55c0eb1 in op_shared_search ldap/servers/slapd/opshared.c:821
    #12 0x7fc6a5607e6a in search_internal_callback_pb ldap/servers/slapd/plugin_internal_op.c:730
    #13 0x7fc6a5606ea7 in search_internal_pb ldap/servers/slapd/plugin_internal_op.c:594
    #14 0x7fc6a56067ba in slapi_search_internal_pb ldap/servers/slapd/plugin_internal_op.c:504
    #15 0x7fc6a56bf134 in vattr_check_thread ldap/servers/slapd/vattr.c:183
    #16 0x7fc6a4a48553 in _pt_root ../../.././nspr/pr/src/pthreads/ptthread.c:201


Indirect leak of 180 byte(s) in 10 object(s) allocated from:
    #0 0x7fc6a5d04627 in __interceptor_malloc (/lib64/libasan.so.6+0xb0627)
    #1 0x7fc6a54dab91 in slapi_ch_malloc ldap/servers/slapd/ch_malloc.c:95
    #2 0x7fc6a56b3e60 in ber_bvcpy ldap/servers/slapd/value.c:48
    #3 0x7fc6a56b3f87 in slapi_ber_bvcpy ldap/servers/slapd/value.c:65
    #4 0x7fc6a5534422 in slapi_filter_dup ldap/servers/slapd/filter.c:702
    #5 0x7fc6a5534669 in slapi_filter_dup ldap/servers/slapd/filter.c:722
    #6 0x7fc6a5534669 in slapi_filter_dup ldap/servers/slapd/filter.c:722
    #7 0x7fc69d54d038 in ldbm_back_search ldap/servers/slapd/back-ldbm/ldbm_search.c:958
    #8 0x7fc6a55c0eb1 in op_shared_search ldap/servers/slapd/opshared.c:821
    #9 0x7fc6a5607e6a in search_internal_callback_pb ldap/servers/slapd/plugin_internal_op.c:730
    #10 0x7fc6a5606ea7 in search_internal_pb ldap/servers/slapd/plugin_internal_op.c:594
    #11 0x7fc6a56067ba in slapi_search_internal_pb ldap/servers/slapd/plugin_internal_op.c:504
    #12 0x7fc6a56bf134 in vattr_check_thread ldap/servers/slapd/vattr.c:183
    #13 0x7fc6a4a48553 in _pt_root ../../.././nspr/pr/src/pthreads/ptthread.c:201


Indirect leak of 256 byte(s) in 2 object(s) allocated from:
    #0 0x7fc6a5d047f7 in __interceptor_calloc (/lib64/libasan.so.6+0xb07f7)
    #1 0x7fc6a54dafd3 in slapi_ch_calloc ldap/servers/slapd/ch_malloc.c:175
    #2 0x7fc6a55341b4 in slapi_filter_dup ldap/servers/slapd/filter.c:685
    #3 0x7fc69d54d038 in ldbm_back_search ldap/servers/slapd/back-ldbm/ldbm_search.c:958
    #4 0x7fc6a55c0eb1 in op_shared_search ldap/servers/slapd/opshared.c:821
    #5 0x4807dd in do_search ldap/servers/slapd/search.c:410
    #6 0x430824 in connection_dispatch_operation ldap/servers/slapd/connection.c:692
    #7 0x436c4f in connection_threadmain ldap/servers/slapd/connection.c:1841
    #8 0x7fc6a4a48553 in _pt_root ../../.././nspr/pr/src/pthreads/ptthread.c:201

Comment 1 mreynolds 2022-08-04 13:20:27 UTC
Upstream ticket:

https://github.com/389ds/389-ds-base/issues/5397

Comment 2 Pierre Rogier 2022-08-04 16:17:00 UTC
FYI: I reproduce the leak while testing another issue on an ASAN build:
So we have a reproducer by simply running:
    pytest $PWD -k test_reset_pwd_before_passwordTPRDelayValidFrom

Comment 3 Akshay Adhikari 2022-08-26 13:31:46 UTC
============================================================================ test session starts =================================================================
platform linux -- Python 3.9.13, pytest-5.4.3, py-1.11.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.9.13', 'Platform': 'Linux-5.14.0-149.el9.x86_64-x86_64-with-glibc2.34', 'Packages': {'pytest': '5.4.3', 'py': '1.11.0', 'pluggy': '0.13.1'}, 'Plugins': {'metadata': '2.0.2', 'html': '3.1.1', 'libfaketime': '0.1.2', 'flaky': '3.7.0'}}
389-ds-base: 2.1.3-3.1asan.el9
nss: 3.79.0-12.el9_0
nspr: 4.34.0-12.el9_0
openldap: 2.6.2-3.el9
cyrus-sasl: 2.1.27-20.el9
FIPS: disabled
rootdir: /root/test/389-ds-base/dirsrvtests, inifile: pytest.ini
plugins: metadata-2.0.2, html-3.1.1, libfaketime-0.1.2, flaky-3.7.0
collected 1 item                                                                                                                                                            

dirsrvtests/tests/suites/password/password_TPR_policy_test.py::test_reset_pwd_before_passwordTPRDelayValidFrom PASSED                                                 [100%]

============================================================================ 1 passed in 12.30s ==================================================================

Marking as Verified: Tested.

Comment 8 errata-xmlrpc 2022-11-15 10:30:16 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 (Moderate: 389-ds-base security, bug fix, and enhancement update), 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/RHSA-2022:8162