Skip to content

Commit 13d49c1

Browse files
Merge pull request #2193 from ggouaillardet/topic/pmix_misc_plugs_and_fixes
pmix3x: plugs misc memory leaks and misc fixes
2 parents 73298ad + f1f1fb1 commit 13d49c1

File tree

7 files changed

+53
-12
lines changed

7 files changed

+53
-12
lines changed

opal/mca/pmix/pmix3x/pmix/config/pmix.m4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[
9090
if test "$?" != "0"; then
9191
AC_MSG_ERROR([Cannot continue])
9292
fi
93+
AC_MSG_RESULT([$PMIX_MAJOR_VERSION])
9394
AC_SUBST(PMIX_MAJOR_VERSION)
9495
AC_DEFINE_UNQUOTED([PMIX_MAJOR_VERSION], [$PMIX_MAJOR_VERSION],
9596
[The library major version is always available, contrary to VERSION])
@@ -98,6 +99,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[
9899
if test "$?" != "0"; then
99100
AC_MSG_ERROR([Cannot continue])
100101
fi
102+
AC_MSG_RESULT([$PMIX_MINOR_VERSION])
101103
AC_SUBST(PMIX_MINOR_VERSION)
102104
AC_DEFINE_UNQUOTED([PMIX_MINOR_VERSION], [$PMIX_MINOR_VERSION],
103105
[The library minor version is always available, contrary to VERSION])
@@ -106,6 +108,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[
106108
if test "$?" != "0"; then
107109
AC_MSG_ERROR([Cannot continue])
108110
fi
111+
AC_MSG_RESULT([$PMIX_RELEASE_VERSION])
109112
AC_SUBST(PMIX_RELEASE_VERSION)
110113
AC_DEFINE_UNQUOTED([PMIX_RELEASE_VERSION], [$PMIX_RELEASE_VERSION],
111114
[The library release version is always available, contrary to VERSION])

opal/mca/pmix/pmix3x/pmix/examples/dynamic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
1616
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved.
18+
* Copyright (c) 2016 Research Organization for Information Science
19+
* and Technology (RIST). All rights reserved.
1820
* $COPYRIGHT$
1921
*
2022
* Additional copyrights may follow
@@ -46,7 +48,7 @@ int main(int argc, char **argv)
4648
uint32_t nprocs;
4749
char nsp2[PMIX_MAX_NSLEN+1];
4850
pmix_app_t *app;
49-
char hostname[MAXHOSTNAMELEN], dir[1024];
51+
char hostname[1024], dir[1024];
5052
pmix_proc_t *peers;
5153
size_t npeers, ntmp=0;
5254
char *nodelist;

opal/mca/pmix/pmix3x/pmix/src/class/pmix_hash_table.h

Lines changed: 24 additions & 1 deletion
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) 2015-2016 Intel, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2016 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2016 Mellanox Technologies, Inc.
1616
* All rights reserved.
@@ -371,6 +371,29 @@ static inline int pmix_next_poweroftwo(int value)
371371
}
372372

373373

374+
/**
375+
* Loop over a hash table.
376+
*
377+
* @param[in] key Key for each item
378+
* @param[in] type Type of key (ui32|ui64|ptr)
379+
* @param[in] value Storage for each item
380+
* @param[in] ht Hash table to iterate over
381+
*
382+
* This macro provides a simple way to loop over the items in a pmix_hash_table_t. It
383+
* is not safe to call pmix_hash_table_remove* from within the loop.
384+
*
385+
* Example Usage:
386+
*
387+
* uint64_t key;
388+
* void * value;
389+
* PMIX_HASH_TABLE_FOREACH(key, uint64, value, ht) {
390+
* do_something(key, value);
391+
* }
392+
*/
393+
#define PMIX_HASH_TABLE_FOREACH(key, type, value, ht) \
394+
for (void *_nptr=NULL; \
395+
PMIX_SUCCESS == pmix_hash_table_get_next_key_##type(ht, &key, (void **)&value, _nptr, &_nptr);)
396+
374397
END_C_DECLS
375398

376399
#endif /* PMIX_HASH_TABLE_H */

opal/mca/pmix/pmix3x/pmix/src/client/pmix_client.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ static void job_data(struct pmix_peer_t *pr, pmix_usock_hdr_t *hdr,
188188
cb->active = false;
189189
return;
190190
}
191+
assert(NULL != nspace);
192+
free(nspace);
191193
/* decode it */
192194
pmix_client_process_nspace_blob(pmix_globals.myid.nspace, buf);
193195
cb->status = PMIX_SUCCESS;
@@ -1120,7 +1122,6 @@ void pmix_client_process_nspace_blob(const char *nspace, pmix_buffer_t *bptr)
11201122
bo = &(kptr->value->data.bo);
11211123
PMIX_CONSTRUCT(&buf2, pmix_buffer_t);
11221124
PMIX_LOAD_BUFFER(&buf2, bo->bytes, bo->size);
1123-
PMIX_RELEASE(kptr);
11241125
/* start by unpacking the rank */
11251126
cnt = 1;
11261127
if (PMIX_SUCCESS != (rc = pmix_bfrop.unpack(&buf2, &rank, &cnt, PMIX_PROC_RANK))) {
@@ -1156,7 +1157,6 @@ void pmix_client_process_nspace_blob(const char *nspace, pmix_buffer_t *bptr)
11561157
bo = &(kptr->value->data.bo);
11571158
PMIX_CONSTRUCT(&buf2, pmix_buffer_t);
11581159
PMIX_LOAD_BUFFER(&buf2, bo->bytes, bo->size);
1159-
PMIX_RELEASE(kptr);
11601160
/* start by unpacking the number of nodes */
11611161
cnt = 1;
11621162
if (PMIX_SUCCESS != (rc = pmix_bfrop.unpack(&buf2, &nnodes, &cnt, PMIX_SIZE))) {
@@ -1225,11 +1225,8 @@ void pmix_client_process_nspace_blob(const char *nspace, pmix_buffer_t *bptr)
12251225
if (PMIX_SUCCESS != (rc = pmix_hash_store(&nsptr->internal, PMIX_RANK_WILDCARD, kptr))) {
12261226
PMIX_ERROR_LOG(rc);
12271227
}
1228-
/* maintain accounting - but note that the kptr remains
1229-
* alive and stored in the hash table! So we cannot reuse
1230-
* it for some other purpose */
1231-
PMIX_RELEASE(kptr);
12321228
}
1229+
PMIX_RELEASE(kptr);
12331230
kptr = PMIX_NEW(pmix_kval_t);
12341231
cnt = 1;
12351232
}

opal/mca/pmix/pmix3x/pmix/src/event/pmix_event_registration.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ static void reg_event_hdlr(int sd, short args, void *cbdata)
337337
}
338338
if (PMIX_ERR_WOULD_BLOCK == rc) {
339339
/* the callback will provide our response */
340+
PMIX_RELEASE(cd);
340341
return;
341342
}
342343
goto ack;
@@ -366,6 +367,7 @@ static void reg_event_hdlr(int sd, short args, void *cbdata)
366367
}
367368
if (PMIX_ERR_WOULD_BLOCK == rc) {
368369
/* the callback will provide our response */
370+
PMIX_RELEASE(cd);
369371
return;
370372
}
371373
goto ack;
@@ -395,7 +397,8 @@ static void reg_event_hdlr(int sd, short args, void *cbdata)
395397
goto ack;
396398
}
397399
if (PMIX_ERR_WOULD_BLOCK == rc) {
398-
/* the callback will provide our response */
400+
/* the callback will provide our response */
401+
PMIX_RELEASE(cd);
399402
return;
400403
}
401404

opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,21 @@ static void nscon(pmix_nspace_t *p)
8585
}
8686
static void nsdes(pmix_nspace_t *p)
8787
{
88+
uint64_t key;
89+
pmix_object_t *obj;
90+
8891
PMIX_LIST_DESTRUCT(&p->nodes);
92+
PMIX_HASH_TABLE_FOREACH(key, uint64, obj, &p->internal) {
93+
if (NULL != obj) {
94+
PMIX_RELEASE(obj);
95+
}
96+
}
8997
PMIX_DESTRUCT(&p->internal);
98+
PMIX_HASH_TABLE_FOREACH(key, uint64, obj, &p->modex) {
99+
if (NULL != obj) {
100+
PMIX_RELEASE(obj);
101+
}
102+
}
90103
PMIX_DESTRUCT(&p->modex);
91104
if (NULL != p->server) {
92105
PMIX_RELEASE(p->server);

opal/mca/pmix/pmix3x/pmix/test/utils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Copyright (c) 2015 Intel, Inc. All rights reserved.
33
* Copyright (c) 2015 Mellanox Technologies, Inc.
44
* All rights reserved.
5+
* Copyright (c) 2016 Research Organization for Information Science
6+
* and Technology (RIST). All rights reserved.
57
* $COPYRIGHT$
68
*
79
* Additional copyrights may follow
@@ -234,9 +236,7 @@ int launch_clients(int num_procs, char *binary, char *** client_env, char ***bas
234236
if (cli_info[counter].pid == 0) {
235237
if( !TEST_VERBOSE_GET() ){
236238
// Hide clients stdout
237-
// TODO: on some systems stdout is a constant, address this
238-
fclose(stdout);
239-
stdout = fopen("/dev/null","w");
239+
freopen("/dev/null","w", stdout);
240240
}
241241
execve(binary, client_argv, *client_env);
242242
/* Does not return */

0 commit comments

Comments
 (0)