From cf534d0c955dbeb1d60f0ef03cebe2d283bd857f Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Fri, 6 Jan 2017 13:09:28 +0900 Subject: [PATCH] ompi/proc: plug a memory leak in ompi_proc_finalize() Signed-off-by: Gilles Gouaillardet --- ompi/proc/proc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ompi/proc/proc.c b/ompi/proc/proc.c index 91e834e725..a5f0ca69e5 100644 --- a/ompi/proc/proc.c +++ b/ompi/proc/proc.c @@ -14,7 +14,7 @@ * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2015 Intel, Inc. All rights reserved - * Copyright (c) 2014-2016 Research Organization for Information Science + * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Mellanox Technologies. All rights reserved. * @@ -43,6 +43,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/runtime/mpiruntime.h" #include "ompi/runtime/params.h" +#include "ompi/mca/pml/pml.h" opal_list_t ompi_proc_list = {{0}}; static opal_mutex_t ompi_proc_lock; @@ -374,7 +375,7 @@ int ompi_proc_complete_init(void) int ompi_proc_finalize (void) { - opal_list_item_t *item; + ompi_proc_t *proc; /* Unregister the local proc from OPAL */ opal_proc_local_set(NULL); @@ -398,8 +399,11 @@ int ompi_proc_finalize (void) * it is thread safe to do so...though it may not -appear- to be so * without walking through the entire list/destructor sequence. */ - while (opal_list_get_end(&ompi_proc_list) != (item = opal_list_get_first(&ompi_proc_list))) { - OBJ_RELEASE(item); + while ((ompi_proc_t *)opal_list_get_end(&ompi_proc_list) != (proc = (ompi_proc_t *)opal_list_get_first(&ompi_proc_list))) { + if (NULL != proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML]) { + MCA_PML_CALL(del_procs(&proc, 1)); + } + OBJ_RELEASE(proc); } /* now destruct the list and thread lock */ OBJ_DESTRUCT(&ompi_proc_list); @@ -703,7 +707,6 @@ ompi_proc_find_and_add(const ompi_process_name_t * name, bool* isnew) */ if (NULL == rproc) { *isnew = true; - rproc = OBJ_NEW(ompi_proc_t); ompi_proc_allocate (name->jobid, name->vpid, &rproc); }