From c32d84154afbe643ff6352887d1cc03de004f425 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Tue, 13 May 2014 21:22:12 +0000 Subject: [PATCH] coll/ml: fix leaks and close all the framework opened It is essential to call mca_base_framework_close for every framework that is opened. coll/ml was not doing this so neither bcol nor sbgp were getting cleaned up. This commit fixes this omission. Also fixed a leak caused by calling OBJ_DESTRUCT for something created with OBJ_NEW. With these changes coll/ml appears to be valgrind clean. cmr=v1.8.2:reviewer=manjugv This commit was SVN r31743. --- ompi/mca/coll/ml/coll_ml_component.c | 24 ++++++++++++++++++++---- ompi/mca/coll/ml/coll_ml_lmngr.c | 2 +- ompi/mca/coll/ml/coll_ml_mca.c | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ompi/mca/coll/ml/coll_ml_component.c b/ompi/mca/coll/ml/coll_ml_component.c index eb1ed6365c..3e682e471b 100644 --- a/ompi/mca/coll/ml/coll_ml_component.c +++ b/ompi/mca/coll/ml/coll_ml_component.c @@ -2,7 +2,7 @@ /* * Copyright (c) 2009-2012 Oak Ridge National Laboratory. All rights reserved. * Copyright (c) 2009-2012 Mellanox Technologies. All rights reserved. - * Copyright (c) 2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2013-2014 Los Alamos National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -394,12 +394,28 @@ static int ml_close(void) } OBJ_DESTRUCT(&cs->memory_manager); + OBJ_DESTRUCT(&cs->pending_tasks_mutex); + OBJ_DESTRUCT(&cs->pending_tasks); + OBJ_DESTRUCT(&cs->active_tasks_mutex); + OBJ_DESTRUCT(&cs->active_tasks); + OBJ_DESTRUCT(&cs->sequential_collectives_mutex); + OBJ_DESTRUCT(&cs->sequential_collectives); /* deregister progress function */ - ret=opal_progress_unregister(coll_ml_progress); + ret = opal_progress_unregister(coll_ml_progress); if (OMPI_SUCCESS != ret ) { - fprintf(stderr," failed to un-register the ml progress function \n"); - fflush(stderr); + OMPI_ERROR_LOG(ret); + return ret; + } + + /* close the sbgp and bcol frameworks */ + if (OMPI_SUCCESS != (ret = mca_base_framework_close(&ompi_sbgp_base_framework))) { + OMPI_ERROR_LOG(ret); + return ret; + } + + if (OMPI_SUCCESS != (ret = mca_base_framework_close(&ompi_bcol_base_framework))) { + OMPI_ERROR_LOG(ret); return ret; } diff --git a/ompi/mca/coll/ml/coll_ml_lmngr.c b/ompi/mca/coll/ml/coll_ml_lmngr.c index 5ea023e4c5..1dcf7a5225 100644 --- a/ompi/mca/coll/ml/coll_ml_lmngr.c +++ b/ompi/mca/coll/ml/coll_ml_lmngr.c @@ -59,7 +59,7 @@ static void destruct_lmngr(mca_coll_ml_lmngr_t *lmngr) while(!opal_list_is_empty(&lmngr->blocks_list)) { item = opal_list_remove_first(&lmngr->blocks_list); - OBJ_DESTRUCT(item); + OBJ_RELEASE(item); } OBJ_DESTRUCT(&lmngr->blocks_list); diff --git a/ompi/mca/coll/ml/coll_ml_mca.c b/ompi/mca/coll/ml/coll_ml_mca.c index ca2f6b984b..46be88c370 100644 --- a/ompi/mca/coll/ml/coll_ml_mca.c +++ b/ompi/mca/coll/ml/coll_ml_mca.c @@ -251,6 +251,7 @@ int mca_coll_ml_register_params(void) "Algorithm to use for broadcast", MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY, &mca_coll_ml_component.bcast_algorithm); + OBJ_RELEASE(new_enum); if (0 > tmp) { ret = tmp; }