From 7f5ccfad5e915394f7c0c9a8c45284e90ffd034d Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 30 Oct 2023 12:24:05 +0000 Subject: [PATCH 1/4] ob1: fix minor memory leak Remove an accidental second OBJ_CONSTRUCT of a local opal_bitmap_t variable "reachable". Signed-off-by: Jeff Squyres (cherry picked from commit d89c462ab36c30259fc6e6afd83451d9ce4d8812) --- ompi/mca/pml/ob1/pml_ob1.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index 2f9b4ca79be..e0516d16fe0 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -26,6 +26,7 @@ * Copyright (c) 2018-2021 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2022 IBM Corporation. All rights reserved + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -382,11 +383,6 @@ int mca_pml_ob1_add_procs(ompi_proc_t** procs, size_t nprocs) if(nprocs == 0) return OMPI_SUCCESS; - OBJ_CONSTRUCT(&reachable, opal_bitmap_t); - rc = opal_bitmap_init(&reachable, (int)nprocs); - if(OMPI_SUCCESS != rc) - return rc; - /* make sure remote procs are using the same PML as us */ if (OMPI_SUCCESS != (rc = mca_pml_base_pml_check_selected("ob1", procs, @@ -394,6 +390,10 @@ int mca_pml_ob1_add_procs(ompi_proc_t** procs, size_t nprocs) return rc; } + if (NULL == mca_bml.bml_add_procs) { + return OMPI_ERR_UNREACH; + } + OBJ_CONSTRUCT(&reachable, opal_bitmap_t); rc = opal_bitmap_init(&reachable, (int)nprocs); if (OMPI_SUCCESS != rc) { From 96b73ee38631be2eaf969d6a9190393513792cef Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 30 Oct 2023 12:27:05 +0000 Subject: [PATCH 2/4] mca_base_framework: fix minor memory leak Even if a framework has its own framework_close function, we still have to mca_base_component_unload() each component (which will be handled safely/properly, regardless of whether the component is statically linked or was opened dynamically) and then remove that component from the framework's list of components. Signed-off-by: Jeff Squyres (cherry picked from commit 9f6785907378c83285b6a5849bd47e7f7bc1ccd1) --- opal/mca/base/mca_base_framework.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opal/mca/base/mca_base_framework.c b/opal/mca/base/mca_base_framework.c index a91260fb9f7..81a76731650 100644 --- a/opal/mca/base/mca_base_framework.c +++ b/opal/mca/base/mca_base_framework.c @@ -7,6 +7,7 @@ * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * Copyright (c) 2018 Triad National Security, LLC. All rights * reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -246,9 +247,11 @@ int mca_base_framework_close(struct mca_base_framework_t *framework) /* close the framework and all of its components */ if (is_open) { + ret = OPAL_SUCCESS; if (NULL != framework->framework_close) { ret = framework->framework_close(); - } else { + } + if (OPAL_SUCCESS == ret) { ret = mca_base_framework_components_close(framework, NULL); } From c4d028f4497b2333d95e43ea9e3ae611ad695fe2 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 30 Oct 2023 12:35:47 +0000 Subject: [PATCH 3/4] btl/tcp: fix minor memory leak When tearing down the BTL TCP component, use the handy OPAL_LIST_DESTRUCT macro to OBJ_RELEASE all elements of the mca_btl_tcp_component.local_ifs list and then OBJ_DESTRUCT -- not OBJ_RELEASE -- the list itself. Signed-off-by: Jeff Squyres (cherry picked from commit 16526a228a3e0e87854b9bc4782b9b98e5aba102) --- opal/mca/btl/tcp/btl_tcp_component.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opal/mca/btl/tcp/btl_tcp_component.c b/opal/mca/btl/tcp/btl_tcp_component.c index 78ce7f8edb8..8df51db9a50 100644 --- a/opal/mca/btl/tcp/btl_tcp_component.c +++ b/opal/mca/btl/tcp/btl_tcp_component.c @@ -20,6 +20,7 @@ * Copyright (c) 2014-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -472,7 +473,7 @@ static int mca_btl_tcp_component_close(void) OBJ_DESTRUCT(&mca_btl_tcp_component.tcp_frag_max); OBJ_DESTRUCT(&mca_btl_tcp_component.tcp_frag_user); OBJ_DESTRUCT(&mca_btl_tcp_component.tcp_lock); - OBJ_DESTRUCT(&mca_btl_tcp_component.local_ifs); + OPAL_LIST_DESTRUCT(&mca_btl_tcp_component.local_ifs); return OPAL_SUCCESS; } From 85497b075a4b4cd57162245cea31068d4d369c15 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 30 Oct 2023 12:37:51 +0000 Subject: [PATCH 4/4] btl/tcp: fix minor memory leak split_and_resolve() destroys an argv as it analyzes it. Fix one case in the loop where argv[i] was accidentally neglected to be freed. Signed-off-by: Jeff Squyres (cherry picked from commit 139530373ee8f81e0f3878f4ea526ca8e221cf42) --- opal/mca/btl/tcp/btl_tcp_component.c | 1 + 1 file changed, 1 insertion(+) diff --git a/opal/mca/btl/tcp/btl_tcp_component.c b/opal/mca/btl/tcp/btl_tcp_component.c index 8df51db9a50..131d9c1fe53 100644 --- a/opal/mca/btl/tcp/btl_tcp_component.c +++ b/opal/mca/btl/tcp/btl_tcp_component.c @@ -668,6 +668,7 @@ static char **split_and_resolve(char **orig_str, char *name, bool reqd) "btl: tcp: Using interface: %s ", argv[i]); opal_argv_append(&interface_count, &interfaces, argv[i]); } + free(argv[i]); continue; }