Skip to content

Commit e0a2435

Browse files
author
Ralph Castain
committed
Ensure we pass the app cwd upwards. Add NULL checks
Signed-off-by: Ralph Castain <rhc@open-mpi.org>
1 parent 4fbc521 commit e0a2435

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ static void process_cbfunc(int sd, short args, void *cbdata)
12401240
pmix_pending_connection_t *pnd = (pmix_pending_connection_t*)cd->cbdata;
12411241
pmix_nspace_t *nptr;
12421242
pmix_rank_info_t *info;
1243+
pmix_peer_t *peer;
12431244
int rc;
12441245
uint32_t u32;
12451246
pmix_info_t ginfo;
@@ -1294,10 +1295,24 @@ static void process_cbfunc(int sd, short args, void *cbdata)
12941295

12951296
/* add this nspace to our pool */
12961297
nptr = PMIX_NEW(pmix_nspace_t);
1298+
if (NULL == nptr) {
1299+
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
1300+
CLOSE_THE_SOCKET(pnd->sd);
1301+
PMIX_RELEASE(pnd);
1302+
PMIX_RELEASE(cd);
1303+
return;
1304+
}
12971305
nptr->nspace = strdup(cd->proc.nspace);
12981306
pmix_list_append(&pmix_server_globals.nspaces, &nptr->super);
12991307
/* add this tool rank to the nspace */
13001308
info = PMIX_NEW(pmix_rank_info_t);
1309+
if (NULL == info) {
1310+
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
1311+
CLOSE_THE_SOCKET(pnd->sd);
1312+
PMIX_RELEASE(pnd);
1313+
PMIX_RELEASE(cd);
1314+
return;
1315+
}
13011316
info->pname.nspace = strdup(cd->proc.nspace);
13021317
info->pname.rank = 0;
13031318
/* need to include the uid/gid for validation */
@@ -1306,7 +1321,14 @@ static void process_cbfunc(int sd, short args, void *cbdata)
13061321
pmix_list_append(&nptr->ranks, &info->super);
13071322

13081323
/* setup a peer object for this tool */
1309-
pmix_peer_t *peer = PMIX_NEW(pmix_peer_t);
1324+
peer = PMIX_NEW(pmix_peer_t);
1325+
if (NULL == peer) {
1326+
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
1327+
CLOSE_THE_SOCKET(pnd->sd);
1328+
PMIX_RELEASE(pnd);
1329+
PMIX_RELEASE(cd);
1330+
return;
1331+
}
13101332
/* mark the peer proc type */
13111333
peer->proc_type = PMIX_PROC_TOOL | pnd->proc_type;
13121334
/* add in the nspace pointer */
@@ -1382,11 +1404,11 @@ static void process_cbfunc(int sd, short args, void *cbdata)
13821404
}
13831405

13841406
/* start the events for this tool */
1385-
pmix_event_assign(&peer->recv_event, pmix_globals.evbase, pnd->sd,
1407+
pmix_event_assign(&peer->recv_event, pmix_globals.evbase, peer->sd,
13861408
EV_READ|EV_PERSIST, pmix_ptl_base_recv_handler, peer);
13871409
pmix_event_add(&peer->recv_event, NULL);
13881410
peer->recv_ev_active = true;
1389-
pmix_event_assign(&peer->send_event, pmix_globals.evbase, pnd->sd,
1411+
pmix_event_assign(&peer->send_event, pmix_globals.evbase, peer->sd,
13901412
EV_WRITE|EV_PERSIST, pmix_ptl_base_send_handler, peer);
13911413
pmix_output_verbose(2, pmix_ptl_base_framework.framework_output,
13921414
"pmix:server tool %s:%d has connected on socket %d",
@@ -1410,6 +1432,10 @@ static void cnct_cbfunc(pmix_status_t status,
14101432

14111433
/* need to thread-shift this into our context */
14121434
cd = PMIX_NEW(pmix_setup_caddy_t);
1435+
if (NULL == cd) {
1436+
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
1437+
return;
1438+
}
14131439
cd->status = status;
14141440
(void)strncpy(cd->proc.nspace, proc->nspace, PMIX_MAX_NSLEN);
14151441
cd->cbdata = cbdata;

opal/mca/pmix/pmix2x/pmix2x_server_north.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@ static pmix_status_t server_spawn_fn(const pmix_proc_t *p,
670670
if (NULL != apps[n].env) {
671671
app->env = opal_argv_copy(apps[n].env);
672672
}
673+
if (NULL != apps[n].cwd) {
674+
app->cwd = strdup(apps[n].cwd);
675+
}
673676
app->maxprocs = apps[n].maxprocs;
674677
for (k=0; k < apps[n].ninfo; k++) {
675678
oinfo = OBJ_NEW(opal_value_t);

0 commit comments

Comments
 (0)