Skip to content

Commit 44c1ff6

Browse files
Merge pull request #2672 from ggouaillardet/topic/misc_memory_leaks
Plug misc memory leaks
2 parents b320882 + 189d7b9 commit 44c1ff6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+413
-156
lines changed

ompi/dpm/dpm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copyright (c) 2011-2015 Los Alamos National Security, LLC. All rights
1717
* reserved.
1818
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
19-
* Copyright (c) 2014-2016 Research Organization for Information Science
19+
* Copyright (c) 2014-2017 Research Organization for Information Science
2020
* and Technology (RIST). All rights reserved.
2121
* $COPYRIGHT$
2222
*
@@ -1182,8 +1182,8 @@ static int disconnect_waitall (int count, ompi_dpm_disconnect_obj **objs)
11821182
for (i=0; i< count; i++ ) {
11831183
if (NULL != objs[i]->reqs ) {
11841184
free(objs[i]->reqs );
1185-
free(objs[i]);
11861185
}
1186+
free(objs[i]);
11871187
}
11881188

11891189
free(reqs);

ompi/mca/mtl/psm2/mtl_psm2_component.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2012-2015 Los Alamos National Security, LLC.
1515
* All rights reserved.
1616
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
17+
* Copyright (c) 2017 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -102,16 +104,24 @@ ompi_mtl_psm2_component_register(void)
102104
static int
103105
ompi_mtl_psm2_component_open(void)
104106
{
107+
int res;
105108
glob_t globbuf;
106109
globbuf.gl_offs = 0;
107110

108111
/* Component available only if Omni-Path hardware is present */
109-
if ((glob("/dev/hfi1_[0-9]", GLOB_DOOFFS, NULL, &globbuf) != 0) &&
110-
(glob("/dev/hfi1_[0-9][0-9]", GLOB_APPEND, NULL, &globbuf) != 0)) {
111-
return OPAL_ERR_NOT_AVAILABLE;
112+
res = glob("/dev/hfi1_[0-9]", GLOB_DOOFFS, NULL, &globbuf);
113+
if (0 == res || GLOB_NOMATCH == res) {
114+
globfree(&globbuf);
115+
}
116+
if (0 != res) {
117+
res = glob("/dev/hfi1_[0-9][0-9]", GLOB_APPEND, NULL, &globbuf);
118+
if (0 == res || GLOB_NOMATCH == res) {
119+
globfree(&globbuf);
120+
}
121+
if (0 != res) {
122+
return OPAL_ERR_NOT_AVAILABLE;
123+
}
112124
}
113-
114-
globfree(&globbuf);
115125

116126
/* Component available only if at least one hfi1 port is ACTIVE */
117127
bool foundOnlineHfi1Port = false;

ompi/proc/proc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
17-
* Copyright (c) 2014-2016 Research Organization for Information Science
17+
* Copyright (c) 2014-2017 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
2020
*
@@ -43,6 +43,7 @@
4343
#include "ompi/datatype/ompi_datatype.h"
4444
#include "ompi/runtime/mpiruntime.h"
4545
#include "ompi/runtime/params.h"
46+
#include "ompi/mca/pml/pml.h"
4647

4748
opal_list_t ompi_proc_list = {{0}};
4849
static opal_mutex_t ompi_proc_lock;
@@ -374,7 +375,7 @@ int ompi_proc_complete_init(void)
374375

375376
int ompi_proc_finalize (void)
376377
{
377-
opal_list_item_t *item;
378+
ompi_proc_t *proc;
378379

379380
/* Unregister the local proc from OPAL */
380381
opal_proc_local_set(NULL);
@@ -398,8 +399,11 @@ int ompi_proc_finalize (void)
398399
* it is thread safe to do so...though it may not -appear- to be so
399400
* without walking through the entire list/destructor sequence.
400401
*/
401-
while (opal_list_get_end(&ompi_proc_list) != (item = opal_list_get_first(&ompi_proc_list))) {
402-
OBJ_RELEASE(item);
402+
while ((ompi_proc_t *)opal_list_get_end(&ompi_proc_list) != (proc = (ompi_proc_t *)opal_list_get_first(&ompi_proc_list))) {
403+
if (NULL != proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML]) {
404+
MCA_PML_CALL(del_procs(&proc, 1));
405+
}
406+
OBJ_RELEASE(proc);
403407
}
404408
/* now destruct the list and thread lock */
405409
OBJ_DESTRUCT(&ompi_proc_list);
@@ -703,7 +707,6 @@ ompi_proc_find_and_add(const ompi_process_name_t * name, bool* isnew)
703707
*/
704708
if (NULL == rproc) {
705709
*isnew = true;
706-
rproc = OBJ_NEW(ompi_proc_t);
707710
ompi_proc_allocate (name->jobid, name->vpid, &rproc);
708711
}
709712

opal/dss/dss_load_unload.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -289,7 +289,7 @@ int opal_value_unload(opal_value_t *kv,
289289
return OPAL_ERR_TYPE_MISMATCH;
290290
}
291291
if (NULL == data ||
292-
(NULL == *data && OPAL_STRING != type && OPAL_BYTE_OBJECT != type)) {
292+
(OPAL_STRING != type && OPAL_BYTE_OBJECT != type && NULL == *data)) {
293293
OPAL_ERROR_LOG(OPAL_ERR_BAD_PARAM);
294294
return OPAL_ERR_BAD_PARAM;
295295
}

opal/mca/base/mca_base_var_enum.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2017 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -23,6 +25,7 @@
2325
#include "opal_config.h"
2426

2527
#include "opal/mca/base/mca_base_var_enum.h"
28+
#include "opal/mca/base/mca_base_vari.h"
2629
#include "opal/mca/base/base.h"
2730
#include "opal/util/argv.h"
2831

@@ -617,6 +620,7 @@ static void mca_base_var_enum_flag_constructor (mca_base_var_enum_flag_t *enumer
617620
enumerator->super.string_from_value = enum_string_from_value_flag;
618621
enumerator->super.dump = enum_dump_flag;
619622
enumerator->super.enum_is_static = false;
623+
enumerator->super.enum_name = NULL;
620624
}
621625

622626
static void mca_base_var_enum_flag_destructor (mca_base_var_enum_flag_t *enumerator)
@@ -628,4 +632,32 @@ static void mca_base_var_enum_flag_destructor (mca_base_var_enum_flag_t *enumera
628632
}
629633
free (enumerator->enum_flags);
630634
}
635+
if (NULL != enumerator->super.enum_name) {
636+
free (enumerator->super.enum_name);
637+
}
638+
}
639+
640+
int mca_base_var_enum_register(const char *project_name, const char *framework_name,
641+
const char *component_name, const char *enum_name,
642+
void *storage)
643+
{
644+
int group_index;
645+
646+
/* Developer error. Storage can not be NULL */
647+
assert (NULL != storage);
648+
649+
/* Create a new parameter entry */
650+
group_index = mca_base_var_group_register (project_name, framework_name, component_name,
651+
NULL);
652+
if (-1 > group_index) {
653+
return group_index;
654+
}
655+
656+
if (0 <= group_index) {
657+
mca_base_var_group_add_enum (group_index, storage);
658+
}
659+
660+
return OPAL_SUCCESS;
661+
662+
/* All done */
631663
}

opal/mca/base/mca_base_var_enum.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2017 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -227,6 +229,9 @@ OPAL_DECLSPEC int mca_base_var_enum_create (const char *name, const mca_base_var
227229
OPAL_DECLSPEC int mca_base_var_enum_create_flag (const char *name, const mca_base_var_enum_value_flag_t flags[],
228230
mca_base_var_enum_flag_t **enumerator);
229231

232+
OPAL_DECLSPEC int mca_base_var_enum_register(const char *project_name, const char *framework_name,
233+
const char *component_name, const char *enum_name,
234+
void *storage);
230235
/* standard enumerators. it is invalid to call OBJ_RELEASE on any of these enumerators */
231236
/**
232237
* Boolean enumerator

opal/mca/base/mca_base_var_group.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2017 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -330,6 +332,7 @@ int mca_base_var_group_deregister (int group_index)
330332
mca_base_var_group_t *group;
331333
int size, ret;
332334
int *params, *subgroups;
335+
opal_object_t ** enums;
333336

334337
ret = mca_base_var_group_get_internal (group_index, &group, false);
335338
if (OPAL_SUCCESS != ret) {
@@ -368,6 +371,12 @@ int mca_base_var_group_deregister (int group_index)
368371
(void) mca_base_pvar_mark_invalid (params[i]);
369372
}
370373

374+
size = opal_value_array_get_size(&group->group_enums);
375+
enums = OPAL_VALUE_ARRAY_GET_BASE(&group->group_enums, opal_object_t *);
376+
for (int i = 0 ; i < size ; ++i) {
377+
OBJ_RELEASE (enums[i]);
378+
}
379+
371380
size = opal_value_array_get_size(&group->group_subgroups);
372381
subgroups = OPAL_VALUE_ARRAY_GET_BASE(&group->group_subgroups, int);
373382
for (int i = 0 ; i < size ; ++i) {
@@ -453,6 +462,34 @@ int mca_base_var_group_add_pvar (const int group_index, const int param_index)
453462
return (int) opal_value_array_get_size (&group->group_pvars) - 1;
454463
}
455464

465+
int mca_base_var_group_add_enum (const int group_index, const void * storage)
466+
{
467+
mca_base_var_group_t *group;
468+
int size, i, ret;
469+
void **params;
470+
471+
ret = mca_base_var_group_get_internal (group_index, &group, false);
472+
if (OPAL_SUCCESS != ret) {
473+
return ret;
474+
}
475+
476+
size = opal_value_array_get_size(&group->group_enums);
477+
params = OPAL_VALUE_ARRAY_GET_BASE(&group->group_enums, void *);
478+
for (i = 0 ; i < size ; ++i) {
479+
if (params[i] == storage) {
480+
return i;
481+
}
482+
}
483+
484+
if (OPAL_SUCCESS !=
485+
(ret = opal_value_array_append_item (&group->group_enums, storage))) {
486+
return ret;
487+
}
488+
489+
/* return the group index */
490+
return (int) opal_value_array_get_size (&group->group_enums) - 1;
491+
}
492+
456493
int mca_base_var_group_get (const int group_index, const mca_base_var_group_t **group)
457494
{
458495
return mca_base_var_group_get_internal (group_index, (mca_base_var_group_t **) group, false);
@@ -495,6 +532,9 @@ static void mca_base_var_group_constructor (mca_base_var_group_t *group)
495532

496533
OBJ_CONSTRUCT(&group->group_pvars, opal_value_array_t);
497534
opal_value_array_init (&group->group_pvars, sizeof (int));
535+
536+
OBJ_CONSTRUCT(&group->group_enums, opal_value_array_t);
537+
opal_value_array_init (&group->group_enums, sizeof(void *));
498538
}
499539

500540
static void mca_base_var_group_destructor (mca_base_var_group_t *group)
@@ -517,6 +557,7 @@ static void mca_base_var_group_destructor (mca_base_var_group_t *group)
517557
OBJ_DESTRUCT(&group->group_subgroups);
518558
OBJ_DESTRUCT(&group->group_vars);
519559
OBJ_DESTRUCT(&group->group_pvars);
560+
OBJ_DESTRUCT(&group->group_enums);
520561
}
521562

522563
int mca_base_var_group_get_count (void)

opal/mca/base/mca_base_var_group.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2017 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -52,6 +54,9 @@ struct mca_base_var_group_t {
5254

5355
/** Integer array of group performance variables */
5456
opal_value_array_t group_pvars;
57+
58+
/** Pointer array of group enums */
59+
opal_value_array_t group_enums;
5560
};
5661

5762
typedef struct mca_base_var_group_t mca_base_var_group_t;

opal/mca/base/mca_base_vari.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2017 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -136,6 +138,13 @@ OPAL_DECLSPEC int mca_base_var_group_add_var (const int group_index, const int p
136138
*/
137139
OPAL_DECLSPEC int mca_base_var_group_add_pvar (const int group_index, const int param_index);
138140

141+
/**
142+
* \internal
143+
*
144+
* Add an enum to a group
145+
*/
146+
OPAL_DECLSPEC int mca_base_var_group_add_enum (const int group_index, const void *storage);
147+
139148
/**
140149
* \internal
141150
*

opal/mca/btl/base/btl_base_frame.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* All rights reserved.
1313
* Copyright (c) 2006-2007 Sun Microsystems, Inc. All rights reserved.
1414
* Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
15-
* Copyright (c) 2015 Research Organization for Information Science
15+
* Copyright (c) 2015-2017 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
1818
* reserved.
@@ -147,7 +147,11 @@ static int mca_btl_base_register(mca_base_register_flag_t flags)
147147
&mca_btl_base_warn_component_unused);
148148

149149
(void) mca_base_var_enum_create_flag ("btl_flags", mca_btl_base_flag_enum_flags, &mca_btl_base_flag_enum);
150+
(void) mca_base_var_enum_register("opal", "btl", "base", "btl_flags",
151+
&mca_btl_base_flag_enum);
150152
(void) mca_base_var_enum_create_flag ("btl_atomic_flags", mca_btl_base_atomic_enum_flags, &mca_btl_base_atomic_enum);
153+
(void) mca_base_var_enum_register("opal", "btl", "base", "btl_atomic_flags",
154+
&mca_btl_base_atomic_enum);
151155

152156
return OPAL_SUCCESS;
153157
}
@@ -204,14 +208,6 @@ static int mca_btl_base_close(void)
204208

205209
OBJ_DESTRUCT(&mca_btl_base_modules_initialized);
206210

207-
if (mca_btl_base_flag_enum) {
208-
OBJ_RELEASE(mca_btl_base_flag_enum);
209-
}
210-
211-
if (mca_btl_base_atomic_enum) {
212-
OBJ_RELEASE(mca_btl_base_atomic_enum);
213-
}
214-
215211
#if 0
216212
/* restore event processing */
217213
opal_event_enable();

0 commit comments

Comments
 (0)