From 8ecada01035e8b90538d72b42510e742870b0671 Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Mar 27 2020 01:00:54 +0000 Subject: Issue 50984 - Memory leaks in disk monitoring Description: Memory leaks are reported by the disk monitoring test suite. The direct leak is related to char **dirs array which is not freed at all. Free the array when we clean up or go to shutdown. Fix disk_monitoring_test.py::test_below_half_of_the_threshold_not_starting_after_shutdown. It should accept different exception when the instance is not started. https://pagure.io/389-ds-base/issue/50984 Reviewed by: firstyear (Thanks!) --- diff --git a/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py b/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py index 200213e..2434bf2 100644 --- a/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py +++ b/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py @@ -576,8 +576,10 @@ def test_below_half_of_the_threshold_not_starting_after_shutdown(topo, setup, re else: subprocess.call(['dd', 'if=/dev/zero', f'of={file_path}', 'bs=1M', f'count={FULL_THR_FILL_SIZE}']) _withouterrorlog(topo, 'topo.standalone.status() == True', 120) - with pytest.raises(subprocess.CalledProcessError): + try: topo.standalone.start() + except (ValueError, subprocess.CalledProcessError): + topo.standalone.log.info("Instance start up has failed as expected") _witherrorlog(topo, f'is too far below the threshold({THRESHOLD_BYTES} bytes). Exiting now', 2) # Verify DS has recovered from shutdown os.remove(file_path) diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 0aa17e0..e7a5c28 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -612,6 +612,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) slapi_be_free(&be); } } + slapi_ch_array_free(dirs); return; } /* @@ -710,6 +711,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) slapi_be_free(&be); } } + slapi_ch_array_free(dirs); g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); return; } diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 9e34926..7d7c9ac 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -957,6 +957,7 @@ main(int argc, char **argv) return_value = 1; goto cleanup; } + slapi_ch_array_free(dirs); } /* log the max fd limit as it is typically set in env/systemd */ slapi_log_err(SLAPI_LOG_INFO, "main",