1
1

Plug a few memory leaks identified by valgrind

Этот коммит содержится в:
Ralph Castain 2015-09-23 15:21:04 -07:00
родитель 1474bb212a
Коммит 749bd4e6fe
7 изменённых файлов: 41 добавлений и 13 удалений

Просмотреть файл

@ -62,9 +62,9 @@ extern int opal_pmix_base_exchange(opal_value_t *info,
OPAL_ERROR_LOG((r)); \ OPAL_ERROR_LOG((r)); \
} \ } \
} \ } \
/* do not destruct the keyval as we don't own */ \ /* opal_value_load makes a copy of the data, so release it */ \
/* the data - the caller will take care of the */ \ _kv.key = NULL; \
/* key and value storage, and the kv itself has none */ \ OBJ_DESTRUCT(&(_kv)); \
} while(0); } while(0);
/** /**

Просмотреть файл

@ -102,9 +102,16 @@ PMIX_CLASS_INSTANCE(pmix_usock_queue_t,
static void scon(pmix_shift_caddy_t *p) static void scon(pmix_shift_caddy_t *p)
{ {
p->active = false; p->active = false;
p->kv = NULL;
p->relfn = NULL; p->relfn = NULL;
p->relcbd = NULL; p->relcbd = NULL;
} }
static void scdes(pmix_shift_caddy_t *p)
{
if (NULL != p->kv) {
PMIX_RELEASE(p->kv);
}
}
PMIX_CLASS_INSTANCE(pmix_shift_caddy_t, PMIX_CLASS_INSTANCE(pmix_shift_caddy_t,
pmix_object_t, pmix_object_t,
scon, NULL); scon, NULL);

Просмотреть файл

@ -131,6 +131,7 @@ int pmix1_abort(int flag, const char *msg,
pmix_proc_t *parray=NULL; pmix_proc_t *parray=NULL;
size_t n, cnt=0; size_t n, cnt=0;
opal_namelist_t *ptr; opal_namelist_t *ptr;
char *tmp;
opal_output_verbose(1, opal_pmix_base_framework.framework_output, opal_output_verbose(1, opal_pmix_base_framework.framework_output,
"PMIx_client abort"); "PMIx_client abort");
@ -141,7 +142,9 @@ int pmix1_abort(int flag, const char *msg,
PMIX_PROC_CREATE(parray, cnt); PMIX_PROC_CREATE(parray, cnt);
n=0; n=0;
OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) {
(void)strncpy(parray[n].nspace, opal_convert_jobid_to_string(ptr->name.jobid), PMIX_MAX_NSLEN); tmp = opal_convert_jobid_to_string(ptr->name.jobid);
(void)strncpy(parray[n].nspace, tmp, PMIX_MAX_NSLEN);
free(tmp);
parray[n].rank = ptr->name.vpid; parray[n].rank = ptr->name.vpid;
++n; ++n;
} }
@ -181,6 +184,7 @@ int pmix1_fence(opal_list_t *procs, int collect_data)
size_t n, cnt=0; size_t n, cnt=0;
opal_namelist_t *ptr; opal_namelist_t *ptr;
pmix_info_t info, *iptr; pmix_info_t info, *iptr;
char *tmp;
opal_output_verbose(1, opal_pmix_base_framework.framework_output, opal_output_verbose(1, opal_pmix_base_framework.framework_output,
"PMIx_client fence"); "PMIx_client fence");
@ -191,7 +195,9 @@ int pmix1_fence(opal_list_t *procs, int collect_data)
PMIX_PROC_CREATE(parray, cnt); PMIX_PROC_CREATE(parray, cnt);
n=0; n=0;
OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) {
(void)strncpy(parray[n].nspace, opal_convert_jobid_to_string(ptr->name.jobid), PMIX_MAX_NSLEN); tmp = opal_convert_jobid_to_string(ptr->name.jobid);
(void)strncpy(parray[n].nspace, tmp, PMIX_MAX_NSLEN);
free(tmp);
parray[n].rank = ptr->name.vpid; parray[n].rank = ptr->name.vpid;
++n; ++n;
} }
@ -230,6 +236,7 @@ int pmix1_fencenb(opal_list_t *procs, int collect_data,
opal_namelist_t *ptr; opal_namelist_t *ptr;
pmix1_opcaddy_t *op; pmix1_opcaddy_t *op;
pmix_info_t info, *iptr; pmix_info_t info, *iptr;
char *tmp;
opal_output_verbose(1, opal_pmix_base_framework.framework_output, opal_output_verbose(1, opal_pmix_base_framework.framework_output,
"PMIx_client fence_nb"); "PMIx_client fence_nb");
@ -240,7 +247,9 @@ int pmix1_fencenb(opal_list_t *procs, int collect_data,
PMIX_PROC_CREATE(parray, cnt); PMIX_PROC_CREATE(parray, cnt);
n=0; n=0;
OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) {
(void)strncpy(parray[n].nspace, opal_convert_jobid_to_string(ptr->name.jobid), PMIX_MAX_NSLEN); tmp = opal_convert_jobid_to_string(ptr->name.jobid);
(void)strncpy(parray[n].nspace, tmp, PMIX_MAX_NSLEN);
free(tmp);
parray[n].rank = ptr->name.vpid; parray[n].rank = ptr->name.vpid;
++n; ++n;
} }
@ -300,6 +309,7 @@ int pmix1_get(const opal_process_name_t *proc, const char *key,
size_t ninfo, n; size_t ninfo, n;
pmix_info_t *pinfo; pmix_info_t *pinfo;
opal_value_t *ival; opal_value_t *ival;
char *tmp;
opal_output_verbose(1, opal_pmix_base_framework.framework_output, opal_output_verbose(1, opal_pmix_base_framework.framework_output,
"%s PMIx_client get on proc %s key %s", "%s PMIx_client get on proc %s key %s",
@ -310,7 +320,9 @@ int pmix1_get(const opal_process_name_t *proc, const char *key,
*val = NULL; *val = NULL;
if (NULL != proc) { if (NULL != proc) {
/* convert the process jobid */ /* convert the process jobid */
(void)strncpy(p.nspace, opal_convert_jobid_to_string(proc->jobid), PMIX_MAX_NSLEN); tmp = opal_convert_jobid_to_string(proc->jobid);
(void)strncpy(p.nspace, tmp, PMIX_MAX_NSLEN);
free(tmp);
p.rank = proc->vpid; p.rank = proc->vpid;
pptr = &p; pptr = &p;
} else { } else {
@ -918,6 +930,7 @@ int pmix1_disconnect(opal_list_t *procs)
pmix_proc_t *parray=NULL; pmix_proc_t *parray=NULL;
size_t n, cnt=0; size_t n, cnt=0;
opal_namelist_t *ptr; opal_namelist_t *ptr;
char *tmp;
/* protect against bozo error */ /* protect against bozo error */
if (NULL == procs || 0 == (cnt = opal_list_get_size(procs))) { if (NULL == procs || 0 == (cnt = opal_list_get_size(procs))) {
@ -929,7 +942,9 @@ int pmix1_disconnect(opal_list_t *procs)
PMIX_PROC_CREATE(parray, cnt); PMIX_PROC_CREATE(parray, cnt);
n=0; n=0;
OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) {
(void)strncpy(parray[n].nspace, opal_convert_jobid_to_string(ptr->name.jobid), PMIX_MAX_NSLEN); tmp = opal_convert_jobid_to_string(ptr->name.jobid);
(void)strncpy(parray[n].nspace, tmp, PMIX_MAX_NSLEN);
free(tmp);
if (OPAL_VPID_WILDCARD == ptr->name.vpid) { if (OPAL_VPID_WILDCARD == ptr->name.vpid) {
parray[n].rank = PMIX_RANK_WILDCARD; parray[n].rank = PMIX_RANK_WILDCARD;
} else { } else {
@ -1004,6 +1019,9 @@ int pmix1_resolve_peers(const char *nodename, opal_jobid_t jobid,
} }
ret = PMIx_Resolve_peers(nodename, nspace, &array, &nprocs); ret = PMIx_Resolve_peers(nodename, nspace, &array, &nprocs);
if (NULL != nspace) {
free(nspace);
}
rc = pmix1_convert_rc(ret); rc = pmix1_convert_rc(ret);
if (NULL != array && 0 < nprocs) { if (NULL != array && 0 < nprocs) {
@ -1012,9 +1030,6 @@ int pmix1_resolve_peers(const char *nodename, opal_jobid_t jobid,
opal_list_append(procs, &nm->super); opal_list_append(procs, &nm->super);
rc = opal_convert_string_to_jobid(&nm->name.jobid, array[n].nspace); rc = opal_convert_string_to_jobid(&nm->name.jobid, array[n].nspace);
if (OPAL_SUCCESS != rc) { if (OPAL_SUCCESS != rc) {
if (NULL != nspace) {
free(nspace);
}
PMIX_PROC_FREE(array, nprocs); PMIX_PROC_FREE(array, nprocs);
return rc; return rc;
} }

Просмотреть файл

@ -354,7 +354,7 @@ void pmix1_value_load(pmix_value_t *v,
default: default:
/* silence warnings */ /* silence warnings */
break; break;
} }
} }
int pmix1_value_unload(opal_value_t *kv, int pmix1_value_unload(opal_value_t *kv,

Просмотреть файл

@ -103,7 +103,7 @@ int orte_ess_base_app_setup(bool db_restrict_local)
* do so here */ * do so here */
if (ORTE_PROC_NON_MPI) { if (ORTE_PROC_NON_MPI) {
orte_process_info.super.proc_name = *(opal_process_name_t*)ORTE_PROC_MY_NAME; orte_process_info.super.proc_name = *(opal_process_name_t*)ORTE_PROC_MY_NAME;
orte_process_info.super.proc_hostname = strdup(orte_process_info.nodename); orte_process_info.super.proc_hostname = orte_process_info.nodename;
orte_process_info.super.proc_flags = OPAL_PROC_ALL_LOCAL; orte_process_info.super.proc_flags = OPAL_PROC_ALL_LOCAL;
orte_process_info.super.proc_arch = opal_local_arch; orte_process_info.super.proc_arch = opal_local_arch;
opal_proc_local_set(&orte_process_info.super); opal_proc_local_set(&orte_process_info.super);

Просмотреть файл

@ -186,6 +186,7 @@ static int rte_init(void)
} }
/* retrieve our topology */ /* retrieve our topology */
val = NULL;
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_LOCAL_TOPO, OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_LOCAL_TOPO,
ORTE_PROC_MY_NAME, &val, OPAL_STRING); ORTE_PROC_MY_NAME, &val, OPAL_STRING);
if (OPAL_SUCCESS == ret && NULL != val) { if (OPAL_SUCCESS == ret && NULL != val) {

Просмотреть файл

@ -309,6 +309,11 @@ int orte_proc_info_finalize(void)
orte_process_info.nodename = NULL; orte_process_info.nodename = NULL;
} }
if (NULL != orte_process_info.cpuset) {
free(orte_process_info.cpuset);
orte_process_info.cpuset = NULL;
}
if (NULL != orte_process_info.sock_stdin) { if (NULL != orte_process_info.sock_stdin) {
free(orte_process_info.sock_stdin); free(orte_process_info.sock_stdin);
orte_process_info.sock_stdin = NULL; orte_process_info.sock_stdin = NULL;